spinetoolbox.spine_db_editor.widgets.custom_editors

Custom editors for model/view programming.

Module Contents

Classes

EventFilterForCatchingRollbackShortcut

CustomComboBoxEditor

CustomLineEditor

A custom QLineEdit to handle data from models.

ParameterValueLineEditor

A custom QLineEdit to handle data from models.

PivotHeaderTableLineEditor

Line editor that is visible on Pivot view's header tables due to a clever hack.

_CustomLineEditDelegate

A delegate for placing a CustomLineEditor on the first row of SearchBarEditor.

SearchBarEditor

A Google-like search bar, implemented as a QTableView with a _CustomLineEditDelegate in the first row.

BooleanSearchBarEditor

A Google-like search bar, implemented as a QTableView with a _CustomLineEditDelegate in the first row.

CheckListEditor

A check list editor.

_IconPainterDelegate

A delegate to highlight decorations in a QListWidget.

IconColorEditor

An editor to let the user select an icon and a color for an object_class.

class spinetoolbox.spine_db_editor.widgets.custom_editors.EventFilterForCatchingRollbackShortcut[source]

Bases: PySide6.QtCore.QObject

eventFilter(obj, event)[source]

Catches Rollback action shortcut (Ctrl+backspace) while editing is in progress.

class spinetoolbox.spine_db_editor.widgets.custom_editors.CustomComboBoxEditor(parent)[source]

Bases: PySide6.QtWidgets.QComboBox

class spinetoolbox.spine_db_editor.widgets.custom_editors.CustomLineEditor(parent)[source]

Bases: PySide6.QtWidgets.QLineEdit

A custom QLineEdit to handle data from models.

set_data(data)[source]

Sets editor’s text.

Parameters

data (Any) – anything convertible to string

data()[source]

Returns editor’s text.

Returns

editor’s text

Return type

str

keyPressEvent(event)[source]

Prevents shift key press to clear the contents.

class spinetoolbox.spine_db_editor.widgets.custom_editors.ParameterValueLineEditor(parent)[source]

Bases: CustomLineEditor

A custom QLineEdit to handle data from models.

set_data(data)[source]

See base class.

data()[source]

See base class.

class spinetoolbox.spine_db_editor.widgets.custom_editors.PivotHeaderTableLineEditor(parent=None)[source]

Bases: CustomLineEditor

Line editor that is visible on Pivot view’s header tables due to a clever hack.

Parameters

parent (QWidget, optional) – parent widget

fix_geometry()[source]

Fixes editor’s position after reparenting.

class spinetoolbox.spine_db_editor.widgets.custom_editors._CustomLineEditDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for placing a CustomLineEditor on the first row of SearchBarEditor.

text_edited[source]
setModelData(editor, model, index)[source]
createEditor(parent, option, index)[source]

Create editor and ‘forward’ textEdited signal.

eventFilter(editor, event)[source]

Handle all sort of special cases.

class spinetoolbox.spine_db_editor.widgets.custom_editors.SearchBarEditor(parent, tutor=None)[source]

Bases: PySide6.QtWidgets.QTableView

A Google-like search bar, implemented as a QTableView with a _CustomLineEditDelegate in the first row.

Parameters
  • parent (QWidget, optional) – parent widget

  • tutor (QWidget, optional) – another widget used for positioning.

data_committed[source]
set_data(current, items)[source]

Populates model.

Parameters
  • current (str) – item that is currently selected from given items

  • items (Sequence of str) – items to show in the list

set_base_offset(offset)[source]

Changes the base offset that is applied to the editor’s position.

Parameters

offset (QPoint) – new offset

update_geometry(option)[source]

Updates geometry.

Parameters

option (QStyleOptionViewItem) – style information

refit()[source]

Changes the position and size of the editor to fit the window.

data()[source]

Returns editor’s final data.

Returns

editor data

Return type

str

_handle_delegate_text_edited(text)[source]

Filters model as the first row is being edited.

Parameters

text (str) – text the user has entered on the first row

_proxy_model_filter_accepts_row(source_row, source_parent)[source]

Always accept first row while filtering the rest.

Parameters
  • source_row (int) – source row index

  • source_parent (QModelIndex) – parent index for source row

Returns

True if row is accepted, False otherwise

Return type

bool

keyPressEvent(event)[source]

Sets data from current index into first index as the user navigates through the table using the up and down keys.

currentChanged(current, previous)[source]
edit_first_index()[source]

Edits first index if valid and not already being edited.

mousePressEvent(event)[source]

Commits data.

class spinetoolbox.spine_db_editor.widgets.custom_editors.BooleanSearchBarEditor(parent, tutor=None)[source]

Bases: SearchBarEditor

A Google-like search bar, implemented as a QTableView with a _CustomLineEditDelegate in the first row.

Parameters
  • parent (QWidget, optional) – parent widget

  • tutor (QWidget, optional) – another widget used for positioning.

data()[source]

Returns editor’s final data.

Returns

editor data

Return type

str

set_data(current, items)[source]

Populates model.

Parameters
  • current (str) – item that is currently selected from given items

  • items (Sequence of str) – items to show in the list

class spinetoolbox.spine_db_editor.widgets.custom_editors.CheckListEditor(parent, tutor=None)[source]

Bases: PySide6.QtWidgets.QTableView

A check list editor.

Parameters
  • parent (QWidget) – parent widget

  • tutor (QWidget, optional) – a widget that helps in positioning

keyPressEvent(event)[source]

Toggles checked state if the user presses space.

toggle_selected(index)[source]

Adds or removes given index from selected items.

Parameters

index (QModelIndex) – index to toggle

mouseMoveEvent(event)[source]

Sets the current index to the one under mouse.

mousePressEvent(event)[source]

Toggles checked state of pressed index.

set_data(items, checked_items)[source]

Sets data and updates geometry.

Parameters
  • items (Sequence(str)) – All items.

  • checked_items (Sequence(str)) – Initially checked items.

data()[source]

Returns a comma separated list of checked items.

Returns

str

update_geometry(option)[source]

Updates geometry.

Parameters

option (QStyleOptionViewItem) – style information

class spinetoolbox.spine_db_editor.widgets.custom_editors._IconPainterDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate to highlight decorations in a QListWidget.

paint(painter, option, index)[source]

Paints selected items using the highlight brush.

class spinetoolbox.spine_db_editor.widgets.custom_editors.IconColorEditor(parent)[source]

Bases: PySide6.QtWidgets.QDialog

An editor to let the user select an icon and a color for an object_class.

Parameters

parent (QWidget) – parent widget

reset_pressed[source]
showEvent(event)[source]
_proxy_model_filter_accepts_row(source_row, source_parent)[source]

Filters icons according to search terms.

Parameters
  • source_row (int) – source row index

  • source_parent (QModelIndex) – parent index for source row

Returns

True if row is accepted, False otherwise

Return type

bool

connect_signals()[source]

Connects signals to slots.

set_data(data)[source]

Sets current icon data.

Parameters

data (int) – database icon data

data()[source]

Gets current icon data.

Returns

database icon data

Return type

int