KDEUI
kextendableitemdelegate.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2006,2007 Andreas Hartmetz (ahartmetz@gmail.com) 00003 Copyright (C) 2008 Urs Wolfer (uwolfer @ kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 00022 #ifndef KEXTENDABLEITEMDELEGATE_H 00023 #define KEXTENDABLEITEMDELEGATE_H 00024 00025 #include <QtGui/QStyledItemDelegate> 00026 00027 #include <kdeui_export.h> 00028 00049 class QAbstractItemView; 00050 00051 class KDEUI_EXPORT KExtendableItemDelegate : public QStyledItemDelegate { 00052 Q_OBJECT 00053 00054 public: 00055 enum auxDataRoles {ShowExtensionIndicatorRole = Qt::UserRole + 200}; 00056 00062 KExtendableItemDelegate(QAbstractItemView *parent); 00063 virtual ~KExtendableItemDelegate(); 00064 00068 virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; 00069 00073 virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; 00074 00081 void extendItem(QWidget *extender, const QModelIndex &index); 00082 00087 void contractItem(const QModelIndex &index); 00088 00092 void contractAll(); 00093 00097 bool isExtended(const QModelIndex &index) const; 00098 00103 virtual void updateExtenderGeometry(QWidget *extender, const QStyleOptionViewItem &option, const QModelIndex &index) const; 00104 00105 Q_SIGNALS: 00109 void extenderCreated(QWidget *extender, const QModelIndex &index); 00110 00114 void extenderDestroyed(QWidget *extender, const QModelIndex &index); 00115 00116 protected: 00123 QRect extenderRect(QWidget *extender, const QStyleOptionViewItem &option, const QModelIndex &index) const; 00124 00128 void setExtendPixmap(const QPixmap &pixmap); 00129 00133 void setContractPixmap(const QPixmap &pixmap); 00134 00138 QPixmap extendPixmap(); 00139 00143 QPixmap contractPixmap(); 00144 00145 00146 private: 00147 class Private; 00148 Private *const d; 00149 00150 Q_PRIVATE_SLOT(d, void _k_extenderDestructionHandler(QObject *destroyed)) 00151 Q_PRIVATE_SLOT(d, void _k_verticalScroll()) 00152 }; 00153 #endif // KEXTENDABLEITEMDELEGATE_H
KDE 4.6 API Reference