2 * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library/Lesser General Public License
6 * version 2, or (at your option) any later version, as published by the
7 * Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library/Lesser General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_KCATEGORIZEDITEMSVIEWDELEGATE_P_H
21 #define PLASMA_KCATEGORIZEDITEMSVIEWDELEGATE_P_H
23 #include <QtCore/QtCore>
24 #include <QtGui/QtGui>
28 #include "kcategorizeditemsviewmodels_p.h"
30 class KCategorizedItemsView
;
32 namespace KCategorizedItemsViewModels
{
37 * Delegate for displaying the items
39 class KCategorizedItemsViewDelegate
: public QItemDelegate
44 KCategorizedItemsViewDelegate(QObject
*parent
= 0);
46 void paint(QPainter
*painter
, const QStyleOptionViewItem
&option
,
47 const QModelIndex
&index
) const;
48 QSize
sizeHint(const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
49 int columnWidth (int column
, int viewWidth
) const;
51 bool editorEvent(QEvent
*event
,
52 QAbstractItemModel
*model
,
53 const QStyleOptionViewItem
&option
,
54 const QModelIndex
&index
);
57 void destroyApplets(const QString
&name
);
58 void infoAboutApplet(const QString
&name
);
61 KCategorizedItemsView
*m_parent
;
63 KIcon m_favoriteAddIcon
;
67 mutable KCategorizedItemsViewModels::AbstractItem
*m_onFavoriteIconItem
;
69 KCategorizedItemsViewModels::AbstractItem
*getItemByProxyIndex(const QModelIndex
& index
) const;
70 void paintColMain(QPainter
*painter
, const QStyleOptionViewItem
&option
,
71 const KCategorizedItemsViewModels::AbstractItem
* item
) const;
72 void paintColFav(QPainter
*painter
, const QStyleOptionViewItem
&option
,
73 const KCategorizedItemsViewModels::AbstractItem
* item
) const;
74 void paintColRemove(QPainter
*painter
, const QStyleOptionViewItem
&option
,
75 const KCategorizedItemsViewModels::AbstractItem
* item
) const;
76 void paintColInfo(QPainter
*painter
, const QStyleOptionViewItem
&option
,
77 const KCategorizedItemsViewModels::AbstractItem
* item
) const;
79 int calcItemHeight(const QStyleOptionViewItem
&option
) const;
83 * Delegate for displaying the filters/categories
85 class KCategorizedItemsViewFilterDelegate
: public QItemDelegate
90 KCategorizedItemsViewFilterDelegate(QObject
*parent
= 0);
92 void paint(QPainter
*painter
, const QStyleOptionViewItem
&option
,
93 const QModelIndex
&index
) const;
94 QSize
sizeHint(const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
97 #endif /*KCATEGORIZEDITEMSVIEWDELEGATE_H_*/