Plasma
delegate.h
Go to the documentation of this file.
00001 /* 00002 Copyright 2007 Robert Knight <robertknight@gmail.com> 00003 Copyright 2008 Marco Martin <notmart@gmail.com> 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 #ifndef PLASMA_DELEGATE_H 00022 #define PLASMA_DELEGATE_H 00023 00024 // Qt 00025 #include <QtGui/QAbstractItemDelegate> 00026 00027 // Plasma 00028 #include <plasma/plasma_export.h> 00029 00030 namespace Plasma 00031 { 00032 00033 class DelegatePrivate; 00034 00052 class PLASMA_EXPORT Delegate : public QAbstractItemDelegate 00053 { 00054 Q_OBJECT 00055 public: 00056 00057 enum SpecificRoles { 00058 SubTitleRole = Qt::UserRole + 1, 00059 SubTitleMandatoryRole = Qt::UserRole + 2, 00060 ColumnTypeRole = Qt::UserRole + 3 00061 }; 00062 00063 enum ColumnType { 00064 MainColumn = 1, 00065 SecondaryActionColumn = 2 00066 }; 00067 00068 Delegate(QObject *parent = 0); 00069 ~Delegate(); 00070 00078 void setRoleMapping(SpecificRoles role, int actual); 00079 00080 int roleMapping(SpecificRoles role) const; 00081 00082 //Reimplemented 00083 virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, 00084 const QModelIndex &index) const; 00085 00089 bool showToolTip() const; 00090 00091 protected: 00101 QRect rectAfterTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const; 00102 00111 QRect rectAfterSubTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const; 00112 00121 QRect emptyRect(const QStyleOptionViewItem &option, const QModelIndex &index) const; 00122 00123 virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; 00124 00125 private: 00126 DelegatePrivate *const d; 00127 }; 00128 00129 } 00130 00131 #endif // PLASMA_DELEGATE_H
KDE 4.6 API Reference