Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkLabelToggleItemDelegate Class Reference

Item delegate for rendering and toggling boolean properties (e.g., visibility, lock) in a QmitkMultiLabelTreeView. More...

#include <QmitkLabelToggleItemDelegate.h>

Inheritance diagram for QmitkLabelToggleItemDelegate:
Collaboration diagram for QmitkLabelToggleItemDelegate:

Public Member Functions

 QmitkLabelToggleItemDelegate (const QIcon &onIcon, const QIcon &offIcon, QObject *parent=nullptr)
 Constructs the toggle item delegate with on/off icons. More...
 
bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 Handles mouse click events to toggle the boolean property. More...
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Paints the on or off icon based on the current value. More...
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Returns the preferred size for the toggle icon. More...
 

Protected Attributes

QIcon m_OnIcon
 
QIcon m_OffIcon
 

Detailed Description

Item delegate for rendering and toggling boolean properties (e.g., visibility, lock) in a QmitkMultiLabelTreeView.

Displays an on/off icon based on the current boolean state and toggles the value on mouse click. Used for visibility and lock columns in the multi-label tree view.

See also
QmitkMultiLabelTreeView
QmitkMultiLabelTreeModel
QmitkLabelColorItemDelegate

Definition at line 32 of file QmitkLabelToggleItemDelegate.h.

Constructor & Destructor Documentation

◆ QmitkLabelToggleItemDelegate()

QmitkLabelToggleItemDelegate::QmitkLabelToggleItemDelegate ( const QIcon &  onIcon,
const QIcon &  offIcon,
QObject *  parent = nullptr 
)
explicit

Constructs the toggle item delegate with on/off icons.

Parameters
[in]onIconThe icon displayed when the property is true/on.
[in]offIconThe icon displayed when the property is false/off.
[in]parentOptional parent QObject.

Member Function Documentation

◆ editorEvent()

bool QmitkLabelToggleItemDelegate::editorEvent ( QEvent *  event,
QAbstractItemModel *  model,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
)
override

Handles mouse click events to toggle the boolean property.

Parameters
[in]eventThe editor event.
[in]modelThe model being edited.
[in]optionThe style option for the item.
[in]indexThe model index of the item.
Returns
True if the event was handled; false otherwise.

◆ paint()

void QmitkLabelToggleItemDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Paints the on or off icon based on the current value.

Parameters
[in]painterThe painter used for rendering.
[in]optionThe style option for the item.
[in]indexThe model index of the item.

◆ sizeHint()

QSize QmitkLabelToggleItemDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Returns the preferred size for the toggle icon.

Parameters
[in]optionThe style option for the item.
[in]indexThe model index of the item.
Returns
The size hint for the delegate.

Member Data Documentation

◆ m_OffIcon

QIcon QmitkLabelToggleItemDelegate::m_OffIcon
protected

Definition at line 75 of file QmitkLabelToggleItemDelegate.h.

◆ m_OnIcon

QIcon QmitkLabelToggleItemDelegate::m_OnIcon
protected

Definition at line 74 of file QmitkLabelToggleItemDelegate.h.


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