spinetoolbox.widgets.custom_editors

Custom editors for model/view programming.

author
  1. Marin (KTH)

date

2.9.2018

Module Contents

Classes

CustomLineEditor

A custom QLineEdit to handle data from models.

ParameterValueLineEditor

A custom QLineEdit to handle data from models.

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

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.widgets.custom_editors.CustomLineEditor[source]

Bases: PySide2.QtWidgets.QLineEdit

A custom QLineEdit to handle data from models.

set_data(self, data)[source]

Sets editor’s text.

Parameters

data (Any) – anything convertible to string

data(self)[source]

Returns editor’s text.

Returns

editor’s text

Return type

str

keyPressEvent(self, event)[source]

Prevents shift key press to clear the contents.

class spinetoolbox.widgets.custom_editors.ParameterValueLineEditor[source]

Bases: CustomLineEditor

A custom QLineEdit to handle data from models.

set_data(self, data)[source]

Sets editor’s text.

Parameters

data (Any) – anything convertible to string

data(self)[source]

Returns editor’s text.

Returns

editor’s text

Return type

str

class spinetoolbox.widgets.custom_editors._CustomLineEditDelegate[source]

Bases: PySide2.QtWidgets.QStyledItemDelegate

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, optional) – another widget used for positioning.

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

Populates model.

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

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

set_base_size(self, size)[source]
set_base_offset(self, offset)[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, ranked=False)[source]

Bases: PySide2.QtWidgets.QTableView

A check list editor.

Initialize class.

_make_icon(self, i=None)[source]
keyPressEvent(self, event)[source]

Toggles checked state if the user presses space.

toggle_selected(self, index)[source]

Adds or removes given index from selected items.

Parameters

index (QModelIndex) – index to toggle

_select_item(self, qitem, rank)[source]
_deselect_item(self, qitem, update_ranks=False)[source]
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.QStyledItemDelegate

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]

Filters icons according to search terms.

connect_signals(self)[source]

Connects signals to slots.

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