KDE3Support
k3iconview.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Torben Weis <weis@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef KICONVIEW_H 00019 #define KICONVIEW_H 00020 00021 #include <kde3support_export.h> 00022 00023 #include <Qt3Support/Q3IconView> 00024 00041 class KDE3SUPPORT_EXPORT K3IconView : public Q3IconView 00042 { 00043 friend class K3IconViewItem; 00044 Q_OBJECT 00045 Q_ENUMS( Mode ) 00046 Q_PROPERTY( Mode mode READ mode WRITE setMode ) 00047 00048 public: 00049 K3IconView( QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0 ); 00050 00051 ~K3IconView(); 00052 00061 enum Mode { Execute, Select }; 00062 00072 void setMode( Mode m ); 00073 00077 Mode mode() const; 00078 00082 virtual void setFont( const QFont & ); 00083 00090 void setIconTextHeight( int n ); 00091 00095 int iconTextHeight() const; 00096 00100 virtual void takeItem( Q3IconViewItem * item ); 00101 00102 Q_SIGNALS: 00103 00113 void executed( Q3IconViewItem *item ); 00114 00125 void executed( Q3IconViewItem *item, const QPoint &pos ); 00126 00135 void held( Q3IconViewItem *item ); 00136 00150 void doubleClicked( Q3IconViewItem *item, const QPoint &pos ); 00151 00152 protected Q_SLOTS: 00153 void slotOnItem( Q3IconViewItem *item ); 00154 void slotOnViewport(); 00155 void slotSettingsChanged(int); 00156 00160 void slotAutoSelect(); 00161 00162 protected: 00163 void emitExecute( Q3IconViewItem *item, const QPoint &pos ); 00164 void updateDragHoldItem( QDropEvent *e ); 00165 00166 virtual void focusOutEvent( QFocusEvent *fe ); 00167 virtual void leaveEvent( QEvent *e ); 00168 virtual void contentsMousePressEvent( QMouseEvent *e ); 00169 virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e ); 00170 virtual void contentsMouseReleaseEvent( QMouseEvent *e ); 00171 virtual void contentsDragEnterEvent( QDragEnterEvent *e ); 00172 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); 00173 virtual void contentsDragMoveEvent( QDragMoveEvent *e ); 00174 virtual void contentsDropEvent( QDropEvent* e ); 00175 virtual void wheelEvent( QWheelEvent *e ); 00176 00183 void cancelPendingHeldSignal(); 00184 00185 private Q_SLOTS: 00186 void slotMouseButtonClicked( int btn, Q3IconViewItem *item, const QPoint &pos ); 00187 void slotDragHoldTimeout(); 00188 00189 private: 00193 QFontMetrics *itemFontMetrics() const; 00197 QPixmap selectedIconPixmap( QPixmap *pix, const QColor &col ) const; 00198 00199 bool m_bUseSingle; 00200 bool m_bChangeCursorOverItem; 00201 00202 Q3IconViewItem* m_pCurrentItem; 00203 00204 QTimer* m_pAutoSelect; 00205 int m_autoSelectDelay; 00206 00207 private: 00208 class K3IconViewPrivate; 00209 K3IconViewPrivate *d; 00210 }; 00211 00212 class KWordWrap; 00221 class KDE3SUPPORT_EXPORT K3IconViewItem : public Q3IconViewItem 00222 { 00223 public: 00224 // Need to redefine all the constructors - I want Java ! 00225 K3IconViewItem( Q3IconView *parent ) 00226 : Q3IconViewItem( parent ) { init(); } // We need to call it because the parent ctor won't call our reimplementation :((( 00227 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after ) 00228 : Q3IconViewItem( parent, after ) { init(); } 00229 K3IconViewItem( Q3IconView *parent, const QString &text ) 00230 : Q3IconViewItem( parent, text ) { init(); } 00231 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text ) 00232 : Q3IconViewItem( parent, after, text ) { init(); } 00233 K3IconViewItem( Q3IconView *parent, const QString &text, const QPixmap &icon ) 00234 : Q3IconViewItem( parent, text, icon ) { init(); } 00235 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text, const QPixmap &icon ) 00236 : Q3IconViewItem( parent, after, text, icon ) { init(); } 00237 K3IconViewItem( Q3IconView *parent, const QString &text, const QPicture &picture ) 00238 : Q3IconViewItem( parent, text, picture ) { init(); } 00239 K3IconViewItem( Q3IconView *parent, Q3IconViewItem *after, const QString &text, const QPicture &picture ) 00240 : Q3IconViewItem( parent, after, text, picture ) { init(); } 00241 virtual ~K3IconViewItem(); 00242 00253 void setPixmapSize( const QSize& size ); 00254 00258 QSize pixmapSize() const; 00259 00260 protected: 00261 void init(); 00262 virtual void calcRect( const QString& text_ = QString() ); 00263 virtual void paintItem( QPainter *p, const QColorGroup &c ); 00264 KWordWrap *wordWrap(); 00265 void paintPixmap( QPainter *p, const QColorGroup &c ); 00266 void paintText( QPainter *p, const QColorGroup &c ); 00267 00268 private: 00269 KWordWrap* m_wordWrap; 00270 struct K3IconViewItemPrivate; 00271 K3IconViewItemPrivate *d; 00272 }; 00273 00274 #endif
KDE 4.6 API Reference