KExtendableItemDelegate

Search for usage in LXR

#include <KExtendableItemDelegate>

Inheritance diagram for KExtendableItemDelegate:

Public Types

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

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)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, 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 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 *context, Functor functor, 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)
 
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QAbstractItemDelegate
 EditNextItem
 
 EditPreviousItem
 
 NoHint
 
 RevertModelCache
 
 SubmitModelCache
 

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.nosp@m.metz.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Since
4.1

Definition at line 40 of file kextendableitemdelegate.h.

Member Enumeration Documentation

◆ auxDataRoles

enum KExtendableItemDelegate::auxDataRoles

Definition at line 45 of file kextendableitemdelegate.h.

Constructor & Destructor Documentation

◆ KExtendableItemDelegate()

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 59 of file kextendableitemdelegate.cpp.

Member Function Documentation

◆ contractAll()

void KExtendableItemDelegate::contractAll ( )

Close all extenders and delete all extender widgets.

Definition at line 110 of file kextendableitemdelegate.cpp.

◆ contractItem()

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 92 of file kextendableitemdelegate.cpp.

◆ contractPixmap()

QPixmap KExtendableItemDelegate::contractPixmap ( )
protected

Return the pixmap that is displayed to contract an item.

Definition at line 406 of file kextendableitemdelegate.cpp.

◆ extenderCreated

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

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

◆ extenderDestroyed

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

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

◆ extenderRect()

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 284 of file kextendableitemdelegate.cpp.

◆ extendItem()

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 68 of file kextendableitemdelegate.cpp.

◆ extendPixmap()

QPixmap KExtendableItemDelegate::extendPixmap ( )
protected

Return the pixmap that is displayed to extend an item.

Definition at line 401 of file kextendableitemdelegate.cpp.

◆ isExtended()

bool KExtendableItemDelegate::isExtended ( const QModelIndex & index) const

Return whether there is an extender that belongs to index.

Definition at line 147 of file kextendableitemdelegate.cpp.

◆ paint()

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 170 of file kextendableitemdelegate.cpp.

◆ setContractPixmap()

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 396 of file kextendableitemdelegate.cpp.

◆ setExtendPixmap()

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 391 of file kextendableitemdelegate.cpp.

◆ sizeHint()

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 152 of file kextendableitemdelegate.cpp.

◆ updateExtenderGeometry()

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 362 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-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.