kdeui
kiconview.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KICONVIEW_H
00019 #define KICONVIEW_H
00020
00021 #include <qcursor.h>
00022 #include <qiconview.h>
00023
00024 #include <kdelibs_export.h>
00025
00042 class KDEUI_EXPORT KIconView : public QIconView
00043 {
00044 friend class KIconViewItem;
00045 Q_OBJECT
00046 Q_ENUMS( Mode )
00047 Q_PROPERTY( Mode mode READ mode WRITE setMode )
00048
00049 public:
00050 KIconView( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00051
00052 ~KIconView();
00053
00062 enum Mode { Execute, Select };
00063
00073 void setMode( Mode m );
00074
00078 Mode mode() const;
00079
00083 virtual void setFont( const QFont & );
00084
00092 void setIconTextHeight( int n );
00093
00098 int iconTextHeight() const;
00099
00103 virtual void takeItem( QIconViewItem * item );
00104
00105 signals:
00106
00116 void executed( QIconViewItem *item );
00117
00128 void executed( QIconViewItem *item, const QPoint &pos );
00129
00138 void held( QIconViewItem *item );
00139
00153 void doubleClicked( QIconViewItem *item, const QPoint &pos );
00154
00155 protected slots:
00156 void slotOnItem( QIconViewItem *item );
00157 void slotOnViewport();
00158 void slotSettingsChanged(int);
00159
00163 void slotAutoSelect();
00164
00165 protected:
00166 void emitExecute( QIconViewItem *item, const QPoint &pos );
00167 void updateDragHoldItem( QDropEvent *e );
00168
00169 virtual void focusOutEvent( QFocusEvent *fe );
00170 virtual void leaveEvent( QEvent *e );
00171 virtual void contentsMousePressEvent( QMouseEvent *e );
00172 virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e );
00173 virtual void contentsMouseReleaseEvent( QMouseEvent *e );
00174 virtual void contentsDragEnterEvent( QDragEnterEvent *e );
00175 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
00176 virtual void contentsDragMoveEvent( QDragMoveEvent *e );
00177 virtual void contentsDropEvent( QDropEvent* e );
00178 virtual void wheelEvent( QWheelEvent *e );
00179
00186 void cancelPendingHeldSignal();
00187
00188 private slots:
00189 void slotMouseButtonClicked( int btn, QIconViewItem *item, const QPoint &pos );
00190 void slotDragHoldTimeout();
00191
00192 private:
00196 QFontMetrics *itemFontMetrics() const;
00200 QPixmap selectedIconPixmap( QPixmap *pix, const QColor &col ) const;
00201
00202 bool m_bUseSingle;
00203 bool m_bChangeCursorOverItem;
00204
00205 QIconViewItem* m_pCurrentItem;
00206
00207 QTimer* m_pAutoSelect;
00208 int m_autoSelectDelay;
00209
00210 protected:
00211 virtual void virtual_hook( int id, void* data );
00212 private:
00213 class KIconViewPrivate;
00214 KIconViewPrivate *d;
00215 };
00216
00217 class KWordWrap;
00226 class KDEUI_EXPORT KIconViewItem : public QIconViewItem
00227 {
00228 public:
00229
00230 KIconViewItem( QIconView *parent )
00231 : QIconViewItem( parent ) { init(); }
00232 KIconViewItem( QIconView *parent, QIconViewItem *after )
00233 : QIconViewItem( parent, after ) { init(); }
00234 KIconViewItem( QIconView *parent, const QString &text )
00235 : QIconViewItem( parent, text ) { init(); }
00236 KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text )
00237 : QIconViewItem( parent, after, text ) { init(); }
00238 KIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon )
00239 : QIconViewItem( parent, text, icon ) { init(); }
00240 KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon )
00241 : QIconViewItem( parent, after, text, icon ) { init(); }
00242 KIconViewItem( QIconView *parent, const QString &text, const QPicture &picture )
00243 : QIconViewItem( parent, text, picture ) { init(); }
00244 KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPicture &picture )
00245 : QIconViewItem( parent, after, text, picture ) { init(); }
00246 virtual ~KIconViewItem();
00247
00259 void setPixmapSize( const QSize& size );
00260
00265 QSize pixmapSize() const;
00266
00267 protected:
00268 void init();
00269 virtual void calcRect( const QString& text_ = QString::null );
00270 virtual void paintItem( QPainter *p, const QColorGroup &c );
00271 KWordWrap *wordWrap();
00272 void paintPixmap( QPainter *p, const QColorGroup &c );
00273 void paintText( QPainter *p, const QColorGroup &c );
00274
00275 private:
00276 KWordWrap* m_wordWrap;
00277 struct KIconViewItemPrivate;
00278 KIconViewItemPrivate *d;
00279 };
00280
00281 #endif