easymodel.widgetdelegate.WidgetDelegateViewMixin

class easymodel.widgetdelegate.WidgetDelegateViewMixin(*args, **kwargs)[source]

Bases: object

Mixin for views to allow editing with mouseclicks, if there is a widgetdelegate.

On a mouse click event, try to edit the index at click position. Then take the editor widget and issue the same click on that widget.

__init__(*args, **kwargs)[source]

Methods

__init__(*args, **kwargs)
get_pos_in_delegate(index, globalpos) Map the global position to the position relative to the
index_at_event(event) Get the index under the position of the given MouseEvent
mouseDoubleClickEvent(event) If a widgetdelegate is double clicked, enter edit mode and propagate the event to the editor widget.
mousePressEvent(event) If the mouse is presses on a widgetdelegate, enter edit mode and propagate the event to the editor widget.
mouseReleaseEvent(event) If the mouse is released on a widgetdelegate, enter edit mode and propagate the event to the editor widget.
propagate_event_to_delegate(event, eventhandler) Propagate the given Mouse event to the widgetdelegate
index_at_event(event)[source]

Get the index under the position of the given MouseEvent

Parameters:event (QtGui.QMouseEvent) – the mouse event
Returns:the index
Return type:QtCore.QModelIndex
Raises:None
get_pos_in_delegate(index, globalpos)[source]

Map the global position to the position relative to the given index

Parameters:
  • index (QtCore.QModelIndex) – the index to map to
  • globalpos (QtCore.QPoint) – the global position
Returns:

The position relative to the given index

Return type:

QtCore.QPoint

Raises:

None

propagate_event_to_delegate(event, eventhandler)[source]

Propagate the given Mouse event to the widgetdelegate

Enter edit mode, get the editor widget and issue an event on that widget.

Parameters:
  • event (QtGui.QMouseEvent) – the mouse event
  • eventhandler (str) – the eventhandler to use. E.g. "mousePressEvent"
Returns:

None

Return type:

None

Raises:

None

mouseDoubleClickEvent(event)[source]

If a widgetdelegate is double clicked, enter edit mode and propagate the event to the editor widget.

Parameters:event (QtGui.QMouseEvent) – the mouse event
Returns:None
Return type:None
Raises:None
mousePressEvent(event)[source]

If the mouse is presses on a widgetdelegate, enter edit mode and propagate the event to the editor widget.

Parameters:event (QtGui.QMouseEvent) – the mouse event
Returns:None
Return type:None
Raises:None
mouseReleaseEvent(event)[source]

If the mouse is released on a widgetdelegate, enter edit mode and propagate the event to the editor widget.

Parameters:event (QtGui.QMouseEvent) – the mouse event
Returns:None
Return type:None
Raises:None