KExtendableItemDelegate

#include <KExtendableItemDelegate>

Inheritance diagram for KExtendableItemDelegate:

Public Types

enum  auxDataRoles { ShowExtensionIndicatorRole = Qt::UserRole + 200 }
 
- Public Types inherited from QAbstractItemDelegate
enum  EndEditHint
 

Signals

void extenderCreated (QWidget *extender, const QModelIndex &index)
 
void extenderDestroyed (QWidget *extender, const QModelIndex &index)
 

Public Member Functions

 KExtendableItemDelegate (QAbstractItemView *parent)
 
void contractAll ()
 
void contractItem (const QModelIndex &index)
 
void extendItem (QWidget *extender, const QModelIndex &index)
 
bool isExtended (const QModelIndex &index) const
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
virtual void updateExtenderGeometry (QWidget *extender, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
- Public Member Functions inherited from QStyledItemDelegate
 QStyledItemDelegate (QObject *parent)
 
virtual QWidgetcreateEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
 
virtual QString displayText (const QVariant &value, const QLocale &locale) const const
 
QItemEditorFactoryitemEditorFactory () const const
 
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const const override
 
void setItemEditorFactory (QItemEditorFactory *factory)
 
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const const override
 
virtual void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
 
- Public Member Functions inherited from QAbstractItemDelegate
 QAbstractItemDelegate (QObject *parent)
 
void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 
void commitData (QWidget *editor)
 
virtual void destroyEditor (QWidget *editor, const QModelIndex &index) const const
 
virtual bool helpEvent (QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
 
void sizeHintChanged (const QModelIndex &index)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

QPixmap contractPixmap ()
 
QRect extenderRect (QWidget *extender, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
QPixmap extendPixmap ()
 
void setContractPixmap (const QPixmap &pixmap)
 
void setExtendPixmap (const QPixmap &pixmap)
 
- Protected Member Functions inherited from QStyledItemDelegate
virtual bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 
virtual bool eventFilter (QObject *editor, QEvent *event) override
 
virtual void initStyleOption (QStyleOptionViewItem *option, const QModelIndex &index) const const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QAbstractItemDelegate
QString elidedText (const QFontMetrics &fontMetrics, int width, Qt::TextElideMode mode, const QString &text)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QAbstractItemDelegate
 EditNextItem
 
 EditPreviousItem
 
 NoHint
 
 RevertModelCache
 
 SubmitModelCache
 
- Public Attributes inherited from QObject
typedef QObjectList
 

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 ahart[email protected]metz[email protected]@gmai[email protected]l.co[email protected]m
Since
4.1

Definition at line 40 of file kextendableitemdelegate.h.

Constructor & Destructor Documentation

KExtendableItemDelegate::KExtendableItemDelegate ( 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.

Definition at line 57 of file kextendableitemdelegate.cpp.

Member Function Documentation

void KExtendableItemDelegate::contractAll ( )

Close all extenders and delete all extender widgets.

Definition at line 109 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::contractItem ( const QModelIndex index)

Remove the extender of item at index from the view.

The extender widget will be deleted.

Definition at line 91 of file kextendableitemdelegate.cpp.

QPixmap KExtendableItemDelegate::contractPixmap ( )
protected

Return the pixmap that is displayed to contract an item.

Definition at line 410 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::extenderCreated ( QWidget extender,
const QModelIndex index 
)
signal

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

void KExtendableItemDelegate::extenderDestroyed ( QWidget extender,
const QModelIndex index 
)
signal

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

QRect KExtendableItemDelegate::extenderRect ( QWidget extender,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
protected

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.

Definition at line 287 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::extendItem ( QWidget extender,
const 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.

Definition at line 67 of file kextendableitemdelegate.cpp.

QPixmap KExtendableItemDelegate::extendPixmap ( )
protected

Return the pixmap that is displayed to extend an item.

Definition at line 405 of file kextendableitemdelegate.cpp.

bool KExtendableItemDelegate::isExtended ( const QModelIndex index) const

Return whether there is an extender that belongs to index.

Definition at line 148 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::paint ( QPainter painter,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
overridevirtual

Re-implemented for internal reasons.

API not affected.

Reimplemented from QStyledItemDelegate.

Definition at line 172 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::setContractPixmap ( const QPixmap pixmap)
protected

The pixmap that is displayed to contract an item.

pixmap must have the same size as the pixmap in setExtendPixmap.

Definition at line 400 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::setExtendPixmap ( const QPixmap pixmap)
protected

The pixmap that is displayed to extend an item.

pixmap must have the same size as the pixmap in setContractPixmap.

Definition at line 395 of file kextendableitemdelegate.cpp.

QSize KExtendableItemDelegate::sizeHint ( const QStyleOptionViewItem option,
const QModelIndex index 
) const
overridevirtual

Re-implemented for internal reasons.

API not affected.

Reimplemented from QStyledItemDelegate.

Definition at line 153 of file kextendableitemdelegate.cpp.

void KExtendableItemDelegate::updateExtenderGeometry ( QWidget extender,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
virtual

Reimplement this function to adjust the internal geometry of the extender.

The external geometry of the extender will be set by the delegate.

Definition at line 365 of file kextendableitemdelegate.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 26 2021 22:39:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.