Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18#ifndef KICONVIEW_H
19#define KICONVIEW_H
20
21#include <kde3support_export.h>
22
23#include <Qt3Support/Q3IconView>
24
25/**
26 * @short A variant of QIconView that honors KDE's system-wide settings.
27 *
28 * This Widget extends the functionality of QIconView to honor the system
29 * wide settings for Single Click/Double Click mode, Auto Selection and
30 * Change Cursor over Link.
31 *
32 * There is a new signal executed(). It gets connected to either
33 * QIconView::clicked() or QIconView::doubleClicked() depending on the KDE
34 * wide Single Click/Double Click settings. It is strongly recommended that
35 * you use this signal instead of the above mentioned. This way you don't
36 * need to care about the current settings.
37 * If you want to get informed when the user selects something connect to the
38 * QIconView::selectionChanged() signal.
39 *
40 **/
41class KDE3SUPPORT_EXPORT K3IconView : public Q3IconView
42{
43 friend class K3IconViewItem;
44 Q_OBJECT
45 Q_ENUMS( Mode )
46 Q_PROPERTY( Mode mode READ mode WRITE setMode )
47
48public:
49 K3IconView( QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0 );
50
51 ~K3IconView();
52
53 /**
54 * K3IconView has two different operating modes. Execute mode is depending
55 * on the configuration of single-click or double-click where the signal
56 * executed() will be emitted upon click/double-click.
57 * In Select mode, this signal will not be emitted.
58 *
59 * Default is Execute mode.
60 */
61 enum Mode { Execute, Select };
62
63 /**
64 * Sets the mode to Execute or Select.
65 * @li In Execute mode, the signal executed()
66 * will be emitted when the user clicks/double-clicks an item.
67 * @li Select mode is
68 * the normal QIconView mode.
69 *
70 * Default is Execute.
71 */
72 void setMode( Mode m );
73
74 /**
75 * @returns the current Mode, either Execute or Select.
76 */
77 Mode mode() const;
78
79 /**
80 * Reimplemented for internal purposes
81 */
82 virtual void setFont( const QFont & );
83
84 /**
85 * Set the maximum number of lines that will be used to display icon text.
86 * Setting this value will enable word-wrap, too.
87 *
88 * @param n Number of lines
89 */
90 void setIconTextHeight( int n );
91
92 /**
93 * @return The height of icon text in lines
94 */
95 int iconTextHeight() const;
96
97 /**
98 * Reimplemented for held() signal behavior internal purposes
99 */
100 virtual void takeItem( Q3IconViewItem * item );
101
102Q_SIGNALS:
103
104 /**
105 * This signal is emitted whenever the user executes an iconview item.
106 * That means depending on the KDE wide Single Click/Double Click
107 * setting the user clicked or double clicked on that item.
108 * @param item is the pointer to the executed iconview item.
109 *
110 * Note that you may not delete any QIconViewItem objects in slots
111 * connected to this signal.
112 */
113 void executed( Q3IconViewItem *item );
114
115 /**
116 * This signal is emitted whenever the user executes an iconview item.
117 * That means depending on the KDE wide Single Click/Double Click
118 * setting the user clicked or double clicked on that item.
119 * @param item is the pointer to the executed iconview item.
120 * @param pos is the position where the user has clicked
121 *
122 * Note that you may not delete any QIconViewItem objects in slots
123 * connected to this signal.
124 */
125 void executed( Q3IconViewItem *item, const QPoint &pos );
126
127 /**
128 * This signal is emitted whenever the user hold something on an iconview
129 * during a drag'n'drop.
130 * @param item is the pointer to the iconview item the hold event occur.
131 *
132 * Note that you may not delete any QIconViewItem objects in slots
133 * connected to this signal.
134 */
135 void held( Q3IconViewItem *item );
136
137 /**
138 * This signal gets emitted whenever the user double clicks into the
139 * iconview.
140 * @param item is the pointer to the clicked iconview item.
141 * @param pos is the position where the user has clicked, and
142 *
143 * Note that you may not delete any QIconViewItem objects in slots
144 * connected to this signal.
145 *
146 * This signal is more or less here for the sake of completeness.
147 * You should normally not need to use this. In most cases it's better
148 * to use executed() instead.
149 */
150 void doubleClicked( Q3IconViewItem *item, const QPoint &pos );
151
152protected Q_SLOTS:
153 void slotOnItem( Q3IconViewItem *item );
154 void slotOnViewport();
155 void slotSettingsChanged(int);
156
157 /**
158 * Auto selection happend.
159 */
160 void slotAutoSelect();
161
162protected:
163 void emitExecute( Q3IconViewItem *item, const QPoint &pos );
164 void updateDragHoldItem( QDropEvent *e );
165
166 virtual void focusOutEvent( QFocusEvent *fe );
167 virtual void leaveEvent( QEvent *e );
168 virtual void contentsMousePressEvent( QMouseEvent *e );
169 virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e );
170 virtual void contentsMouseReleaseEvent( QMouseEvent *e );
171 virtual void contentsDragEnterEvent( QDragEnterEvent *e );
172 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
173 virtual void contentsDragMoveEvent( QDragMoveEvent *e );
174 virtual void contentsDropEvent( QDropEvent* e );
175 virtual void wheelEvent( QWheelEvent *e );
176
177 /**
178 * This method allows to handle correctly cases where a subclass
179 * needs the held() signal to not be triggered without calling
180 * a K3IconView::contentsDrag*Event() method (which have side effects
181 * because they forward to QIconView).
182 */
183 void cancelPendingHeldSignal();
184
185private Q_SLOTS:
186 void slotMouseButtonClicked( int btn, Q3IconViewItem *item, const QPoint &pos );
187 void slotDragHoldTimeout();
188
189private:
190 /**
191 * @internal. For use by K3IconViewItem.
192 */
193 QFontMetrics *itemFontMetrics() const;
194 /**
195 * @internal. For use by K3IconViewItem.
196 */
197 QPixmap selectedIconPixmap( QPixmap *pix, const QColor &col ) const;
198
199 bool m_bUseSingle;
200 bool m_bChangeCursorOverItem;
201
202 Q3IconViewItem* m_pCurrentItem;
203
204 QTimer* m_pAutoSelect;
205 int m_autoSelectDelay;
206
207private:
208 class K3IconViewPrivate;
209 K3IconViewPrivate *d;
210};
211
212class KWordWrap;
213/**
214 * @short A variant of QIconViewItem that wraps words better.
215 *
216 * K3IconViewItem exists to improve the word-wrap functionality of QIconViewItem
217 * Use K3IconViewItem instead of QIconViewItem for any iconview item you might have :)
218 *
219 * @author David Faure <faure@kde.org>
220 */
221class KDE3SUPPORT_EXPORT K3IconViewItem : public Q3IconViewItem
222{
223public:
224 // Need to redefine all the constructors - I want Java !
225 K3IconViewItem( Q3IconView *parent )
226 : Q3IconViewItem( parent ) { init(); } // We need to call it because the parent ctor won't call our reimplementation :(((
227 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after )
228 : Q3IconViewItem( parent, after ) { init(); }
229 K3IconViewItem( Q3IconView *parent, const QString &text )
230 : Q3IconViewItem( parent, text ) { init(); }
231 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text )
232 : Q3IconViewItem( parent, after, text ) { init(); }
233 K3IconViewItem( Q3IconView *parent, const QString &text, const QPixmap &icon )
234 : Q3IconViewItem( parent, text, icon ) { init(); }
235 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text, const QPixmap &icon )
236 : Q3IconViewItem( parent, after, text, icon ) { init(); }
237 K3IconViewItem( Q3IconView *parent, const QString &text, const QPicture &picture )
238 : Q3IconViewItem( parent, text, picture ) { init(); }
239 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text, const QPicture &picture )
240 : Q3IconViewItem( parent, after, text, picture ) { init(); }
241 virtual ~K3IconViewItem();
242
243 /**
244 * Using this function, you can specify a custom size for the pixmap. The
245 * geometry of the item will be calculated to let a pixmap of the given size
246 * fit in the iconView without needing an update.
247 * This may be useful if you want to change the pixmap later without breaking
248 * the layout. A possible use of this function is to replace a fileItem icon
249 * by a larger pixmap (preview).
250 *
251 * @param size The size to use
252 */
253 void setPixmapSize( const QSize& size );
254
255 /**
256 * @return The size set by setPixmapSize() or QSize( 0, 0 )
257 */
258 QSize pixmapSize() const;
259
260protected:
261 void init();
262 virtual void calcRect( const QString& text_ = QString() );
263 virtual void paintItem( QPainter *p, const QColorGroup &c );
264 KWordWrap *wordWrap();
265 void paintPixmap( QPainter *p, const QColorGroup &c );
266 void paintText( QPainter *p, const QColorGroup &c );
267
268private:
269 KWordWrap* m_wordWrap;
270 struct K3IconViewItemPrivate;
271 K3IconViewItemPrivate *d;
272};
273
274#endif
275

Warning: That file was not part of the compilation database. It may have many parsing errors.