KDE 4.9 PyKDE API Reference

- KDE's Python API

# KExtendableItemDelegate Class Reference

`from PyKDE4.kdeui import *`

Inherits: QStyledItemDelegate → QAbstractItemDelegate → QObject

## Detailed Description

This delegate makes it possible to display an arbitrary QWidget ("extender") that spans all columns below a line of items. The extender will logically belong to a column in the row above it.

It is your responsibility to devise a way to trigger extension and contraction of items, by calling extendItem() and contractItem(). You can e.g. reimplement itemActivated() and similar functions.

Warning:
  extendItem() reparents the provided widget extender to the viewport of the itemview it belongs to. The extender is destroyed when you call contractItem() for the associated index. If you fail to do that and the associated item gets deleted you're in trouble. It remains as a visible artefact in your treeview. Additionally when closing your application you get an assertion failure from KExtendableItemDelegate. Make sure that you always call contractItem for indices before you delete them.

Author:
  Andreas Hartmetz <ahartmetz@gmail.com>

Since:
  4.1

## Enumerations

auxDataRoles | { ShowExtensionIndicatorRole }

## Signals

| extenderCreated (QWidget extender, QModelIndex index)
| extenderDestroyed (QWidget extender, QModelIndex index)

## Methods

| __init__ (self, QAbstractItemView parent)
| contractAll (self)
| contractItem (self, QModelIndex index)
QPixmap | contractPixmap (self)
| extendItem (self, QWidget extender, QModelIndex index)
QPixmap | extendPixmap (self)
QRect | extenderRect (self, QWidget extender, QStyleOptionViewItem option, QModelIndex index)
bool | isExtended (self, QModelIndex index)
| paint (self, QPainter painter, QStyleOptionViewItem option, QModelIndex index)
| setContractPixmap (self, QPixmap pixmap)
| setExtendPixmap (self, QPixmap pixmap)
QSize | sizeHint (self, QStyleOptionViewItem option, QModelIndex index)
| updateExtenderGeometry (self, QWidget extender, QStyleOptionViewItem option, QModelIndex index)

## Signal Documentation

extenderCreated | ( | QWidget | extender,
|  | QModelIndex | index
| ) |  |  |

This signal indicates that the item at index was extended with extender.

Signal syntax:
  `QObject.connect(source, SIGNAL("extenderCreated(QWidget*, const QModelIndex&)"), target_slot)`

extenderDestroyed | ( | QWidget | extender,
|  | QModelIndex | index
| ) |  |  |

This signal indicates that the extender belonging to index has emitted the destroyed() signal.

Signal syntax:
  `QObject.connect(source, SIGNAL("extenderDestroyed(QWidget*, const QModelIndex&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QAbstractItemView | parent
| ) |  |  |

Create a new KExtendableItemDelegate that belongs to parent. In contrast to generic QAbstractItemDelegates, an instance of this class can only ever be the delegate for one instance of af QAbstractItemView subclass.

contractAll | ( |  | self ) |

Close all extenders and delete all extender widgets.

contractItem | ( | self, |
|  | QModelIndex | index
| ) |  |  |

Remove the extender of item at index from the view. The extender widget will be deleted.

QPixmap contractPixmap | ( |  | self ) |

Return the pixmap that is displayed to contract an item.

extendItem | ( | self, |
|  | QWidget | extender,
|  | QModelIndex | index
| ) |  |  |

Insert the extender for item at index into the view. If you need a parent for the extender at construction time, use the itemview's viewport(). The delegate takes ownership of the extender; the extender will also be reparented and resized to the viewport.

QPixmap extendPixmap | ( |  | self ) |

Return the pixmap that is displayed to extend an item.

QRect extenderRect | ( | self, |
|  | QWidget | extender,
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

Reimplement this function to fine-tune the position of the extender. option.rect will be a rectangle that is as wide as the viewport and as high as the usual item height plus the extender size hint's height. Its upper left corner will be at the upper left corner of the usual item. You can place the returned rectangle of this function anywhere inside that area.

bool isExtended | ( | self, |
|  | QModelIndex | index
| ) |  |  |

Return whether there is an extender that belongs to index.

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

Re-implemented for internal reasons. API not affected.

setContractPixmap | ( | self, |
|  | QPixmap | pixmap
| ) |  |  |

The pixmap that is displayed to contract an item. pixmap must have the same size as the pixmap in setExtendPixmap.

setExtendPixmap | ( | self, |
|  | QPixmap | pixmap
| ) |  |  |

The pixmap that is displayed to extend an item. pixmap must have the same size as the pixmap in setContractPixmap.

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

Re-implemented for internal reasons. API not affected.

updateExtenderGeometry | ( | self, |
|  | QWidget | extender,
|  | QStyleOptionViewItem | option,
|  | QModelIndex | index
| ) |  |  |

Reimplement this function to adjust the internal geometry of the extender. The external geometry of the extender will be set by the delegate.

## Enumeration Documentation

auxDataRoles

Enumerator:

  ShowExtensionIndicatorRole = Qt::UserRole+200 |