Plasma.Delegate

KDE 4.2 PyKDE API Reference

- KDE's Python API

# Delegate Class Reference

`from PyKDE4.plasma import *`

Inherits: QAbstractItemDelegate → QObject
Namespace: Plasma

## Detailed Description

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) 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)

## Enumerations
ColumnType | { MainColumn, SecondaryActionColumn }
SpecificRoles | { SubTitleRole, SubTitleMandatoryRole, ColumnTypeRole }
## Methods
| __init__ (self, QObject parent=0)
QRect | emptyRect (self, QStyleOptionViewItem option, QModelIndex index)
| paint (self, QPainter painter, QStyleOptionViewItem option, QModelIndex index)
QRect | rectAfterSubTitle (self, QStyleOptionViewItem option, QModelIndex index)
QRect | rectAfterTitle (self, QStyleOptionViewItem option, QModelIndex index)
int | roleMapping (self, Plasma.Delegate.SpecificRoles role)
| setRoleMapping (self, Plasma.Delegate.SpecificRoles role, int actual)
bool | showToolTip (self)
QSize | sizeHint (self, QStyleOptionViewItem option, QModelIndex index)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

QRect emptyRect | ( | self, |
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

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

Parameters:

  | option | options for the title and subtitle text
  | index | model index that we want to compute the free area

paint | ( | self, |
|  | QPainter | painter,
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

QRect rectAfterSubTitle | ( | self, |
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

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.

Parameters:

  | option | options for the subtitle text
  | index | model index that we want to compute the free area

QRect rectAfterTitle | ( | self, |
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

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.

Parameters:

  | option | options for the title text
  | index | model index that we want to compute the free area

int roleMapping | ( | self, |
|  | Plasma.Delegate.SpecificRoles | role
| ) |  |  |

setRoleMapping | ( | self, |
|  | Plasma.Delegate.SpecificRoles | role,
|  | int | actual
| ) |  |  |

Maps an arbitrary role to a role belonging to SpecificRoles. Using this function you can use any model with this delegate.

Parameters:

  | role | a role belonging to SpecificRoles
  | actual | an arbitrary role of the model we are using

bool showToolTip | ( |  | self ) |

Returns:
  true if a tooltip should be shown

QSize sizeHint | ( | self, |
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

## Enumeration Documentation

ColumnType

Enumerator:

  MainColumn = 1 |
  SecondaryActionColumn = 2 |

SpecificRoles

Enumerator:

  SubTitleRole = Qt::UserRole+1 |
  SubTitleMandatoryRole = Qt::UserRole+2 |
  ColumnTypeRole = Qt::UserRole+3 |