spinetoolbox.spine_db_editor.widgets.custom_delegates

Custom item delegates.

Module Contents

Classes

PivotTableDelegateMixin

A mixin that fixes Pivot table's header table editor position.

RelationshipPivotTableDelegate

A mixin that fixes Pivot table's header table editor position.

ScenarioAlternativeTableDelegate

A mixin that fixes Pivot table's header table editor position.

ParameterPivotTableDelegate

A mixin that fixes Pivot table's header table editor position.

ParameterValueElementDelegate

Delegate for Array and Map editors' table cells.

TableDelegate

Base class for all custom stacked table delegates.

DatabaseNameDelegate

A delegate for the database name.

ParameterValueOrDefaultValueDelegate

A delegate for either the value or the default value.

ParameterDefaultValueDelegate

A delegate for the default value.

ParameterValueDelegate

A delegate for the parameter_value.

ValueListDelegate

A delegate for the parameter value list.

EntityClassNameDelegate

A delegate for the object_class name.

ParameterNameDelegate

A delegate for the object parameter name.

EntityBynameDelegate

A delegate for the entity byname.

AlternativeNameDelegate

A delegate for the alternative name.

BooleanValueDelegate

Base class for all custom stacked table delegates.

AlternativeDelegate

A delegate for the alternative tree.

ScenarioDelegate

A delegate for the scenario tree.

ParameterDefinitionNameAndDescriptionDelegate

A delegate for the parameter_name and description columns in Parameter Definition Table View.

ParameterValueListDelegate

A delegate for the parameter value list tree.

ManageItemsDelegate

A custom delegate for the model in {Add/Edit}ItemDialogs.

ManageEntityClassesDelegate

A delegate for the model and view in {Add/Edit}EntityClassesDialog.

ManageEntitiesDelegate

A delegate for the model and view in {Add/Edit}EntitiesDialog.

RemoveEntitiesDelegate

A delegate for the model and view in RemoveEntitiesDialog.

MetadataDelegate

A delegate for the name and value columns in Metadata Table View.

ItemMetadataDelegate

A delegate for name and value columns in item metadata editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.PivotTableDelegateMixin[source]

A mixin that fixes Pivot table’s header table editor position.

updateEditorGeometry(editor, option, index)[source]

Fixes position of header table editors.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.RelationshipPivotTableDelegate(parent)[source]

Bases: PivotTableDelegateMixin, spinetoolbox.widgets.custom_delegates.CheckBoxDelegate

A mixin that fixes Pivot table’s header table editor position.

Parameters

parent (SpineDBEditor) – parent widget, i.e. the database editor

data_committed[source]
static _is_relationship_index(index)[source]

Checks whether the given index corresponds to a relationship, in which case we need to use the check box delegate.

Parameters

index (QModelIndex) – index to check

Returns

True if index corresponds to relationship, False otherwise

Return type

bool

setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

paint(painter, option, index)[source]

Paint a checkbox without the label.

editorEvent(event, model, option, index)[source]

Change the data in the model and the state of the checkbox when user presses left mouse button and this cell is editable. Otherwise do nothing.

createEditor(parent, option, index)[source]

Important, otherwise an editor is created if the user clicks in this cell. ** Need to hook up a signal to the model.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ScenarioAlternativeTableDelegate(parent)[source]

Bases: PivotTableDelegateMixin, spinetoolbox.widgets.custom_delegates.RankDelegate

A mixin that fixes Pivot table’s header table editor position.

Parameters

parent (SpineDBEditor) – database editor

data_committed[source]
static _is_scenario_alternative_index(index)[source]

Checks whether or not the given index corresponds to a scenario alternative, in which case we need to use the rank delegate.

Returns

bool

setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

paint(painter, option, index)[source]

Paint a checkbox without the label.

editorEvent(event, model, option, index)[source]

Change the data in the model and the state of the checkbox when user presses left mouse button and this cell is editable. Otherwise do nothing.

createEditor(parent, option, index)[source]

Important, otherwise an editor is created if the user clicks in this cell. ** Need to hook up a signal to the model.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterPivotTableDelegate(parent)[source]

Bases: PivotTableDelegateMixin, PySide6.QtWidgets.QStyledItemDelegate

A mixin that fixes Pivot table’s header table editor position.

Parameters

parent (SpineDBEditor) – parent widget, i.e. database editor

parameter_value_editor_requested[source]
data_committed[source]
setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

createEditor(parent, option, index)[source]
class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterValueElementDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

Delegate for Array and Map editors’ table cells.

value_editor_requested[source]

Emitted when editing the value requires the full blown editor dialog.

setModelData(editor, model, index)[source]

Sets data in the model.

editor (CustomLineEditor): editor widget model (QAbstractItemModel): model index (QModelIndex): target index

createEditor(parent, option, index)[source]

Creates an editor widget or emits value_editor_requested for complex values.

Parameters
  • parent (QWidget) – parent widget

  • option (QStyleOptionViewItem) – unused

  • index (QModelIndex) – element’s model index

Returns

editor widget

Return type

ParameterValueLineEditor

class spinetoolbox.spine_db_editor.widgets.custom_delegates.TableDelegate(parent, db_mngr)[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

Base class for all custom stacked table delegates.

db_mngr

database manager

Type

SpineDBManager

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

data_committed[source]
setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

updateEditorGeometry(editor, option, index)[source]
_close_editor(editor, index)[source]

Closes editor. Needed by SearchBarEditor.

_get_db_map(index)[source]

Returns the db_map for the database at given index or None if not set yet.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.DatabaseNameDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the database name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterValueOrDefaultValueDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for either the value or the default value.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDatabaseManager) – database manager

parameter_value_editor_requested[source]
setModelData(editor, model, index)[source]

Send signal.

_create_or_request_parameter_value_editor(parent, index)[source]

Emits the signal to request a standalone ParameterValueEditor from parent widget.

Parameters
  • parent (QWidget) – editor’s parent widget

  • index (QModelIndex) – index to parameter value model

Returns

editor or None if parameter_value_editor_request signal was emitted

Return type

ParameterValueLineEditor

abstract _get_value_list_id(index, db_map)[source]

Returns a value list id for the given index and db_map.

Parameters
  • index (QModelIndex) – value list’s index

  • db_map (DiffDatabaseMapping) – database mapping

Returns

value list id

Return type

int

createEditor(parent, option, index)[source]

If the parameter has associated a value list, returns a SearchBarEditor. Otherwise, returns or requests a dedicated parameter_value editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterDefaultValueDelegate(parent, db_mngr)[source]

Bases: ParameterValueOrDefaultValueDelegate

A delegate for the default value.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDatabaseManager) – database manager

_get_value_list_id(index, db_map)[source]

See base class

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterValueDelegate(parent, db_mngr)[source]

Bases: ParameterValueOrDefaultValueDelegate

A delegate for the parameter_value.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDatabaseManager) – database manager

_get_value_list_id(index, db_map)[source]

See base class.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ValueListDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the parameter value list.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.EntityClassNameDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the object_class name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterNameDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the object parameter name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.EntityBynameDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the entity byname.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

element_name_list_editor_requested[source]
createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.AlternativeNameDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the alternative name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

createEditor(parent, option, index)[source]

Returns editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.BooleanValueDelegate(parent, db_mngr)[source]

Bases: TableDelegate

Base class for all custom stacked table delegates.

db_mngr

database manager

Type

SpineDBManager

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

setModelData(editor, model, index)[source]

Sends signal.

createEditor(parent, option, index)[source]

Returns editor.

classmethod make_editor(parent, tutor, index)[source]
class spinetoolbox.spine_db_editor.widgets.custom_delegates.AlternativeDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for the alternative tree.

data_committed[source]
setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

createEditor(parent, option, index)[source]

Returns editor.

_close_editor(editor, index)[source]

Closes editor.

Needed by SearchBarEditor.

Parameters
  • editor (QWidget) – editor widget

  • index (QModelIndex) – index that is being edited

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ScenarioDelegate(*args, **kwargs)[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for the scenario tree.

Parameters
  • *args – arguments passed to QStyledItemDelegate

  • **kwargs – keyword arguments passed to QStyledItemDelegate

data_committed[source]
setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

_update_alternative_ids(item)[source]

Updates available alternatives avoiding duplicates in a scenario.

Excludes alternatives that are already in the scenario

Parameters

item (ScenarioAlternativeItem) – one of scenario’s scenario alternatives

Returns

available alternative names

Return type

list of str

createEditor(parent, option, index)[source]

Returns editor.

updateEditorGeometry(editor, option, index)[source]
_close_editor(editor, index)[source]

Closes editor.

Needed by SearchBarEditor.

Parameters
  • editor (QWidget) – editor widget

  • index (QModelIndex) – index that is being edited

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterDefinitionNameAndDescriptionDelegate(parent, db_mngr)[source]

Bases: TableDelegate

A delegate for the parameter_name and description columns in Parameter Definition Table View.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

createEditor(parent, option, index)[source]
class spinetoolbox.spine_db_editor.widgets.custom_delegates.ParameterValueListDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for the parameter value list tree.

data_committed[source]
parameter_value_editor_requested[source]
setModelData(editor, model, index)[source]

Send signal.

setEditorData(editor, index)[source]

Do nothing. We’re setting editor data right away in createEditor.

createEditor(parent, option, index)[source]

Returns editor.

_close_editor(editor, index)[source]

Closes editor.

Needed by SearchBarEditor.

Parameters
  • editor (QWidget) – editor widget

  • index (QModelIndex) – index that is being edited

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ManageItemsDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A custom delegate for the model in {Add/Edit}ItemDialogs.

data_committed[source]
setModelData(editor, model, index)[source]

Send signal.

close_editor(editor, index)[source]

Closes editor.

Needed by SearchBarEditor.

Parameters
  • editor (QWidget) – editor widget

  • index (QModelIndex) – index that is being edited

updateEditorGeometry(editor, option, index)[source]
connect_editor_signals(editor, index)[source]

Connect editor signals if necessary.

Parameters
  • editor (QWidget) – editor widget

  • index (QModelIndex) – index being edited

_create_database_editor(parent, index)[source]

Creates an editor.

Parameters
  • parent (QWidget) – parent widget

  • index (QModelIndex) – index being edited

Returns

editor

Return type

QWidget

createEditor(parent, option, index)[source]

Returns an editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ManageEntityClassesDelegate[source]

Bases: ManageItemsDelegate

A delegate for the model and view in {Add/Edit}EntityClassesDialog.

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

Get a pixmap from the index data and paint it in the middle of the cell.

createEditor(parent, option, index)[source]

Return editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.ManageEntitiesDelegate[source]

Bases: ManageItemsDelegate

A delegate for the model and view in {Add/Edit}EntitiesDialog.

createEditor(parent, option, index)[source]

Return editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.RemoveEntitiesDelegate[source]

Bases: ManageItemsDelegate

A delegate for the model and view in RemoveEntitiesDialog.

createEditor(parent, option, index)[source]

Return editor.

class spinetoolbox.spine_db_editor.widgets.custom_delegates.MetadataDelegate[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for the name and value columns in Metadata Table View.

setEditorData(editor, index)[source]
createEditor(parent, option, index)[source]
class spinetoolbox.spine_db_editor.widgets.custom_delegates.ItemMetadataDelegate(item_metadata_model, metadata_model, column, parent)[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

A delegate for name and value columns in item metadata editor.

Parameters
  • item_metadata_model (ItemMetadataModel) – item metadata model

  • metadata_model (MetadataTableModel) – metadata model

  • column (int) – item metadata table column

  • parent (QObject, optional) – parent object

createEditor(parent, option, index)[source]