spinetoolbox.widgets.custom_editors

Custom editors for model/view programming.

author:
  1. Marin (KTH)
date:

2.9.2018

Module Contents

class spinetoolbox.widgets.custom_editors.CustomLineEditor[source]

Bases: PySide2.QtWidgets.QLineEdit

A custom QLineEdit to handle data from models.

set_data(self, data)[source]
data(self)[source]
keyPressEvent(self, event)[source]

Prevents shift key press to clear the contents.

class spinetoolbox.widgets.custom_editors.CustomComboEditor[source]

Bases: PySide2.QtWidgets.QComboBox

A custom QComboBox to handle data from models.

data_committed[source]
set_data(self, current_text, items)[source]
data(self)[source]
class spinetoolbox.widgets.custom_editors.CustomLineEditDelegate[source]

Bases: PySide2.QtWidgets.QItemDelegate

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

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

Create editor and ‘forward’ textEdited signal.

eventFilter(self, editor, event)[source]

Handle all sort of special cases.

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

Bases: PySide2.QtWidgets.QTableView

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

Initializes instance.

Parameters:
  • parent (QWidget) – parent widget
  • tutor (QWidget, NoneType) – another widget used for positioning.
data_committed[source]
set_data(self, current, items)[source]

Populates model.

Parameters:
  • current (str) –
  • items (Sequence(str)) –
set_base_size(self, size)[source]
update_geometry(self)[source]

Updates geometry.

refit(self)[source]
data(self)[source]
_handle_delegate_text_edited(self, text)[source]

Filters model as the first row is being edited.

_proxy_model_filter_accepts_row(self, source_row, source_parent)[source]

Always accept first row.

keyPressEvent(self, event)[source]

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

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

Edits first index if valid and not already being edited.

mouseMoveEvent(self, event)[source]

Sets the current index to the one hovered by the mouse.

mousePressEvent(self, event)[source]

Commits data.

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

Bases: PySide2.QtWidgets.QTableView

A check list editor.

Initialize class.

keyPressEvent(self, event)[source]

Toggles checked state if the user presses space.

toggle_checked_state(self, index)[source]

Toggles checked state of given index.

Parameters:index (QModelIndex) –
mouseMoveEvent(self, event)[source]

Sets the current index to the one under mouse.

mousePressEvent(self, event)[source]

Toggles checked state of pressed index.

set_data(self, items, checked_items)[source]

Sets data and updates geometry.

Parameters:
  • items (Sequence(str)) – All items.
  • checked_items (Sequence(str)) – Initially checked items.
data(self)[source]

Returns a comma separated list of checked items.

Returns
str
set_base_size(self, size)[source]
update_geometry(self)[source]

Updates geometry.

class spinetoolbox.widgets.custom_editors.IconPainterDelegate[source]

Bases: PySide2.QtWidgets.QItemDelegate

A delegate to highlight decorations in a QListWidget.

paint(self, painter, option, index)[source]

Paints selected items using the highlight brush.

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

Bases: PySide2.QtWidgets.QDialog

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

Init class.

_proxy_model_filter_accepts_row(self, source_row, source_parent)[source]

Overridden method to filter icons according to search terms.

connect_signals(self)[source]

Connect signals to slots.

set_data(self, data)[source]
data(self)[source]
class spinetoolbox.widgets.custom_editors.NumberParameterInlineEditor(parent)[source]

Bases: PySide2.QtWidgets.QDoubleSpinBox

An editor widget for numeric (datatype double) parameter values.

set_data(self, data)[source]
data(self)[source]