digiKam
Digikam::DWItemDelegate Class Referenceabstract
+ Inheritance diagram for Digikam::DWItemDelegate:

Public Member Functions

 DWItemDelegate (QAbstractItemView *const itemView, QObject *const parent=nullptr)
 
QPersistentModelIndex focusedIndex () const
 
QAbstractItemView * itemView () const
 
 ~DWItemDelegate () override
 

Protected Member Functions

QList< QEvent::Type > blockedEventTypes (QWidget *const widget) const
 
virtual QList< QWidget * > createItemWidgets (const QModelIndex &index) const =0
 
void setBlockedEventTypes (QWidget *const widget, const QList< QEvent::Type > &types) const
 
virtual void updateItemWidgets (const QList< QWidget * > &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const =0
 

Friends

class DWItemDelegateEventListener
 
class DWItemDelegatePool
 

Detailed Description

This class allows to create item delegates embedding simple widgets to interact with items. For instance you can add push buttons, line edits, etc. to your delegate and use them to modify the state of your model.

Constructor & Destructor Documentation

◆ DWItemDelegate()

Digikam::DWItemDelegate::DWItemDelegate ( QAbstractItemView *const  itemView,
QObject *const  parent = nullptr 
)
explicit

Creates a new ItemDelegate to be used with a given itemview.

Parameters
itemViewthe item view the new delegate will monitor
parentthe parent of this delegate

References itemView(), and Digikam::DWItemDelegatePrivate::itemView.

◆ ~DWItemDelegate()

Digikam::DWItemDelegate::~DWItemDelegate ( )
override

Member Function Documentation

◆ blockedEventTypes()

QList< QEvent::Type > Digikam::DWItemDelegate::blockedEventTypes ( QWidget *const  widget) const
protected

Retrieves the list of blocked event types for the given widget.

Parameters
widgetthe specified widget.
Returns
the list of blocked event types, can be empty if no events are blocked.

◆ createItemWidgets()

virtual QList<QWidget*> Digikam::DWItemDelegate::createItemWidgets ( const QModelIndex &  index) const
protectedpure virtual

Creates the list of widgets needed for an item.

Note
No initialization of the widgets is supposed to happen here. The widgets will be initialized based on needs for a given item.
If you want to connect some widget signals to any slot, you should do it here.
  • index the index to create widgets for.
Note
If you want to know the index for which you are creating widgets, it is available as a QModelIndex Q_PROPERTY called "goya:creatingWidgetsForIndex". Ensure to add Q_DECLARE_METATYPE(QModelIndex) before your method definition to tell QVariant about QModelIndex.
Returns
the list of newly created widgets which will be used to interact with an item.
See also
updateItemWidgets()

Implemented in Digikam::SetupCollectionDelegate.

Referenced by Digikam::DWItemDelegatePool::findWidgets().

◆ focusedIndex()

QPersistentModelIndex Digikam::DWItemDelegate::focusedIndex ( ) const

Retrieves the currently focused index. An invalid index if none is focused.

Returns
the current focused index, or QPersistentModelIndex() if none is focused.

References Digikam::DWItemDelegatePrivate::itemView, Digikam::DWItemDelegatePoolPrivate::widgetInIndex, and Digikam::DWItemDelegatePrivate::widgetPool.

◆ itemView()

QAbstractItemView * Digikam::DWItemDelegate::itemView ( ) const

Retrieves the item view this delegate is monitoring.

Returns
the item view this delegate is monitoring

References Digikam::DWItemDelegatePrivate::itemView.

Referenced by DWItemDelegate(), and Digikam::SetupCollectionDelegate::updateItemWidgets().

◆ setBlockedEventTypes()

void Digikam::DWItemDelegate::setBlockedEventTypes ( QWidget *const  widget,
const QList< QEvent::Type > &  types 
) const
protected

Sets the list of event types that a widget will block.

Blocked events are not passed to the view. This way you can prevent an item from being selected when a button is clicked for instance.

Parameters
widgetthe widget which must block events
typesthe list of event types the widget must block

◆ updateItemWidgets()

virtual void Digikam::DWItemDelegate::updateItemWidgets ( const QList< QWidget * > &  widgets,
const QStyleOptionViewItem &  option,
const QPersistentModelIndex &  index 
) const
protectedpure virtual

Updates a list of widgets for its use inside of the delegate (painting or event handling).

Note
All the positioning and sizing should be done in item coordinates.
Warning
Do not make widget connections in here, since this method will be called very regularly.
Parameters
widgetsthe widgets to update
optionthe current set of style options for the view.
indexthe model index of the item currently manipulated.

Implemented in Digikam::SetupCollectionDelegate.

Referenced by Digikam::DWItemDelegatePool::findWidgets().

Friends And Related Function Documentation

◆ DWItemDelegateEventListener

friend class DWItemDelegateEventListener
friend

◆ DWItemDelegatePool

friend class DWItemDelegatePool
friend

The documentation for this class was generated from the following files: