File indexing completed on 2024-04-21 16:29:35
0001 /* 0002 * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com> 0003 * Copyright (C) 2008-2011 Daniel Nicoletti <dantti12@gmail.com> 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library/Lesser General Public License 0007 * version 2, or (at your option) any later version, as published by the 0008 * Free Software Foundation 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details 0014 * 0015 * You should have received a copy of the GNU Library/Lesser General Public 0016 * License along with this program; if not, write to the 0017 * Free Software Foundation, Inc., 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef CHANGES_DELEGATE_H 0022 #define CHANGES_DELEGATE_H 0023 0024 #include <KExtendableItemDelegate> 0025 0026 /** 0027 * Delegate for displaying the packages 0028 */ 0029 class Q_DECL_EXPORT ChangesDelegate: public KExtendableItemDelegate 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit ChangesDelegate(QAbstractItemView *parent); 0035 0036 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0037 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0038 bool editorEvent(QEvent *event, 0039 QAbstractItemModel *model, 0040 const QStyleOptionViewItem &option, 0041 const QModelIndex &index) override; 0042 void setExtendPixmapWidth(int width); 0043 void setViewport(QWidget *viewport); 0044 0045 Q_SIGNALS: 0046 void showExtendItem(const QModelIndex &index); 0047 0048 private: 0049 int calcItemHeight(const QStyleOptionViewItem &option) const; 0050 bool insideButton(const QRect &rect, const QPoint &pos) const; 0051 0052 QWidget *m_viewport; 0053 QIcon m_packageIcon; 0054 QIcon m_collectionIcon; 0055 QIcon m_installIcon; 0056 QString m_installString; 0057 QIcon m_removeIcon; 0058 QString m_removeString; 0059 QIcon m_undoIcon; 0060 QString m_undoString; 0061 QIcon m_checkedIcon; 0062 int m_extendPixmapWidth; 0063 QSize m_buttonSize; 0064 QSize m_buttonIconSize; 0065 }; 0066 0067 #endif