/usr/include/plasma/delegate.h is in kdelibs5-dev 4:4.8.4-4+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | /*
Copyright 2007 Robert Knight <robertknight@gmail.com>
Copyright 2008 Marco Martin <notmart@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_DELEGATE_H
#define PLASMA_DELEGATE_H
// Qt
#include <QtGui/QAbstractItemDelegate>
// Plasma
#include <plasma/plasma_export.h>
namespace Plasma
{
class DelegatePrivate;
/**
* @class Delegate plasma/delegate.h <Plasma/Delegate>
*
* Item delegate for rendering items in Plasma menus implemented with item views.
*
* The delegate makes use of its own data roles that are:
* SubTitleRole: the text of the subtitle
* SubTitleMandatoryRole: if the subtitle is to always be displayed
* (as default the subtitle is displayed only on mouse over)
* NOTE: if model doesn't return a valid data for SubTitleMandatoryRole (i.e. if it returns QVaraint())
* then subtitles will be shown for adjasent items with the same content and not shown
* otherwise.
*
* ColumnTypeRole: if the column is a main column (with title and subtitle)
* or a secondary action column (only a little icon that appears on mouse
* over is displayed)
*/
class PLASMA_EXPORT Delegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
enum SpecificRoles {
SubTitleRole = Qt::UserRole + 1,
SubTitleMandatoryRole = Qt::UserRole + 2,
ColumnTypeRole = Qt::UserRole + 3
};
enum ColumnType {
MainColumn = 1,
SecondaryActionColumn = 2
};
Delegate(QObject *parent = 0);
~Delegate();
/**
* Maps an arbitrary role to a role belonging to SpecificRoles.
* Using this function you can use any model with this delegate.
*
* @param role a role belonging to SpecificRoles
* @param actual an arbitrary role of the model we are using
*/
void setRoleMapping(SpecificRoles role, int actual);
int roleMapping(SpecificRoles role) const;
//Reimplemented
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
/**
* @return true if a tooltip should be shown
*/
bool showToolTip() const;
protected:
/**
* Returns the empty area after the title.
* The height is the height of the subtitle.
* It can be used by subclasses that wants to paint additional data after
* calling the paint function of the superclass.
*
* @param option options for the title text
* @param index model index that we want to compute the free area
*/
QRect rectAfterTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* Returns the empty area after the subtitle.
* The height is the height of the subtitle.
* It can be used by subclasses, that wants to paint additional data.
*
* @param option options for the subtitle text
* @param index model index that we want to compute the free area
*/
QRect rectAfterSubTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* Returns the empty area after both the title and the subtitle.
* The height is the height of the item.
* It can be used by subclasses that wants to paint additional data
*
* @param option options for the title and subtitle text
* @param index model index that we want to compute the free area
*/
QRect emptyRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
DelegatePrivate *const d;
};
}
#endif // PLASMA_DELEGATE_H
|