digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::DWItemDelegate Class Referenceabstract

This class allows to create item delegates embedding simple widgets to interact with items. More...

+ Inheritance diagram for Digikam::DWItemDelegate:

Public Member Functions

 DWItemDelegate (QAbstractItemView *const itemView, QObject *const parent=nullptr)
 Creates a new ItemDelegate to be used with a given itemview.
 
QPersistentModelIndex focusedIndex () const
 Retrieves the currently focused index.
 
QAbstractItemView * itemView () const
 Retrieves the item view this delegate is monitoring.
 

Protected Member Functions

QList< QEvent::Type > blockedEventTypes (QWidget *const widget) const
 Retrieves the list of blocked event types for the given widget.
 
virtual QList< QWidget * > createItemWidgets (const QModelIndex &index) const =0
 Creates the list of widgets needed for an item.
 
void setBlockedEventTypes (QWidget *const widget, const QList< QEvent::Type > &types) const
 Sets the list of event types that a widget will block.
 
virtual void updateItemWidgets (const QList< QWidget * > &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const =0
 Updates a list of widgets for its use inside of the delegate (painting or event handling).
 

Friends

class DWItemDelegateEventListener
 
class DWItemDelegatePool
 

Detailed Description

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
Parameters
itemViewthe item view the new delegate will monitor
parentthe parent of this delegate

Member Function Documentation

◆ blockedEventTypes()

QList< QEvent::Type > Digikam::DWItemDelegate::blockedEventTypes ( QWidget *const  widget) const
protected
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
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.

◆ focusedIndex()

QPersistentModelIndex Digikam::DWItemDelegate::focusedIndex ( ) const

An invalid index if none is focused.

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

◆ itemView()

QAbstractItemView * Digikam::DWItemDelegate::itemView ( ) const
Returns
the item view this delegate is monitoring

◆ setBlockedEventTypes()

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

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