2007-09-26 09:44:06 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-10-12 10:44:02 +02:00
|
|
|
* it under the terms of the GNU Library/Lesser General Public License
|
|
|
|
* version 2, or (at your option) any later version, as published by the
|
|
|
|
* Free Software Foundation
|
2007-09-26 09:44:06 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
2007-10-12 10:44:02 +02:00
|
|
|
* You should have received a copy of the GNU Library/Lesser General Public
|
2007-09-26 09:44:06 +02:00
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-10-12 12:48:53 +02:00
|
|
|
#ifndef PLASMA_KCATEGORIZEDITEMSVIEWDELEGATE_P_H
|
|
|
|
#define PLASMA_KCATEGORIZEDITEMSVIEWDELEGATE_P_H
|
2007-09-26 09:44:06 +02:00
|
|
|
|
2007-12-10 20:50:31 +01:00
|
|
|
#include <QtCore/QtCore>
|
|
|
|
#include <QtGui/QtGui>
|
2007-09-27 20:51:31 +02:00
|
|
|
|
2007-09-26 09:44:06 +02:00
|
|
|
#include <KIcon>
|
2007-09-27 20:51:31 +02:00
|
|
|
|
|
|
|
#include "kcategorizeditemsviewmodels_p.h"
|
2007-09-26 09:44:06 +02:00
|
|
|
|
|
|
|
class KCategorizedItemsView;
|
|
|
|
|
|
|
|
namespace KCategorizedItemsViewModels {
|
|
|
|
class AbstractItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delegate for displaying the items
|
|
|
|
*/
|
|
|
|
class KCategorizedItemsViewDelegate: public QItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-10-12 02:18:08 +02:00
|
|
|
|
2007-09-26 09:44:06 +02:00
|
|
|
public:
|
|
|
|
KCategorizedItemsViewDelegate(QObject *parent = 0);
|
2008-10-12 02:18:08 +02:00
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) const;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2007-09-26 09:44:06 +02:00
|
|
|
int columnWidth (int column, int viewWidth) const;
|
2008-10-12 02:18:08 +02:00
|
|
|
|
2007-09-26 09:44:06 +02:00
|
|
|
bool editorEvent(QEvent *event,
|
|
|
|
QAbstractItemModel *model,
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index);
|
|
|
|
|
2007-12-10 02:18:57 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void destroyApplets(const QString name);
|
2007-09-26 09:44:06 +02:00
|
|
|
private:
|
2008-10-12 02:18:08 +02:00
|
|
|
|
|
|
|
KCategorizedItemsView *m_parent;
|
2007-09-26 09:44:06 +02:00
|
|
|
KIcon m_favoriteIcon;
|
|
|
|
KIcon m_favoriteAddIcon;
|
2007-12-10 02:18:57 +01:00
|
|
|
KIcon m_removeIcon;
|
2008-10-12 02:18:08 +02:00
|
|
|
|
|
|
|
mutable KCategorizedItemsViewModels::AbstractItem *m_onFavoriteIconItem;
|
|
|
|
|
|
|
|
KCategorizedItemsViewModels::AbstractItem *getItemByProxyIndex(const QModelIndex & index) const;
|
|
|
|
void paintColMain(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
|
|
|
void paintColFav(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
|
|
|
void paintColRemove(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
|
|
|
|
2008-05-25 17:34:59 +02:00
|
|
|
int calcItemHeight(const QStyleOptionViewItem &option) const;
|
2007-09-26 09:44:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delegate for displaying the filters/categories
|
|
|
|
*/
|
|
|
|
class KCategorizedItemsViewFilterDelegate: public QItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-10-12 02:18:08 +02:00
|
|
|
|
2007-09-26 09:44:06 +02:00
|
|
|
public:
|
|
|
|
KCategorizedItemsViewFilterDelegate(QObject *parent = 0);
|
2008-10-12 02:18:08 +02:00
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) const;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2007-09-26 09:44:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*KCATEGORIZEDITEMSVIEWDELEGATE_H_*/
|