spinetoolbox.spine_db_editor.widgets.custom_delegates

Custom item delegates.

author
  1. Marin (KTH)

date

1.9.2018

Module Contents

Classes

RelationshipPivotTableDelegate

A delegate that places a fully functioning QCheckBox.

ScenarioAlternativeTableDelegate

A delegate that places a QCheckBox but draws a number instead of the check.

ParameterPivotTableDelegate

param parent

ParameterValueElementDelegate

Delegate for Array and Map editors’ table cells.

ParameterDelegate

Base class for all custom parameter delegates.

DatabaseNameDelegate

A delegate for the database name.

ParameterValueOrDefaultValueDelegate

A delegate for the either the value or the default value.

ParameterDefaultValueDelegate

A delegate for the either the default value.

ParameterValueDelegate

A delegate for the parameter_value.

TagListDelegate

A delegate for the parameter_tag list.

ValueListDelegate

A delegate for the parameter_value-list.

ObjectClassNameDelegate

A delegate for the object_class name.

RelationshipClassNameDelegate

A delegate for the relationship_class name.

ParameterNameDelegate

A delegate for the object parameter name.

ObjectNameDelegate

A delegate for the object name.

AlternativeNameDelegate

A delegate for the object name.

ObjectNameListDelegate

A delegate for the object name list.

ToolFeatureDelegate

A delegate for the tool feature tree.

AlternativeScenarioDelegate

A delegate for the alternative scenario tree.

ParameterValueListDelegate

A delegate for the parameter value list tree.

ManageItemsDelegate

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

ManageObjectClassesDelegate

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

ManageObjectsDelegate

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

ManageRelationshipClassesDelegate

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

ManageRelationshipsDelegate

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

RemoveEntitiesDelegate

A delegate for the model and view in RemoveEntitiesDialog.

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

Bases: spinetoolbox.widgets.custom_delegates.CheckBoxDelegate

A delegate that places a fully functioning QCheckBox.

Parameters

parent (SpineDBEditor) –

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

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

Returns

bool

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

Send signal.

setEditorData(self, editor, index)[source]

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

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

Paint a checkbox without the label.

editorEvent(self, 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(self, 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: spinetoolbox.widgets.custom_delegates.RankDelegate

A delegate that places a QCheckBox but draws a number instead of the check.

Parameters

parent (SpineDBEditor) –

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(self, editor, model, index)[source]

Send signal.

setEditorData(self, editor, index)[source]

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

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

Paint a checkbox without the label.

editorEvent(self, 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(self, 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: PySide2.QtWidgets.QStyledItemDelegate

Parameters

parent (SpineDBEditor) –

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

Send signal.

setEditorData(self, editor, index)[source]

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

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

Bases: PySide2.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(self, editor, model, index)[source]

Sets data in the model.

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

createEditor(self, 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.ParameterDelegate(parent, db_mngr)[source]

Bases: PySide2.QtWidgets.QStyledItemDelegate

Base class for all custom parameter delegates.

db_mngr

database manager

Type

SpineDBManager

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Send signal.

setEditorData(self, editor, index)[source]

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

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

Closes editor. Needed by SearchBarEditor.

_get_db_map(self, 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: ParameterDelegate

A delegate for the database name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the either the value or the default value.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Send signal.

_create_or_request_parameter_value_editor(self, parent, option, index, db_map)[source]

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

createEditor(self, 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 either the default value.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

_get_value_list_id(self, index, db_map)[source]

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

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 (SpineDBManager) – database manager

_get_value_list_id(self, index, db_map)[source]

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

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

Bases: ParameterDelegate

A delegate for the parameter_tag list.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the parameter_value-list.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the object_class name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the relationship_class name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the object parameter name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the object name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the object name.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

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

Returns editor.

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

Bases: ParameterDelegate

A delegate for the object name list.

Parameters
  • parent (QWidget) – parent widget

  • db_mngr (SpineDBManager) – database manager

object_name_list_editor_requested[source]
createEditor(self, parent, option, index)[source]

Returns editor.

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

Bases: PySide2.QtWidgets.QStyledItemDelegate

A delegate for the tool feature tree.

data_committed[source]
static _get_names(item, model)[source]
static _get_index_data(item, index)[source]
setModelData(self, editor, model, index)[source]

Send signal.

setEditorData(self, editor, index)[source]

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

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

Returns editor.

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

Closes editor. Needed by SearchBarEditor.

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

Bases: PySide2.QtWidgets.QStyledItemDelegate

A delegate for the alternative scenario tree.

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

Send signal.

setEditorData(self, editor, index)[source]

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

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

Returns editor.

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

Closes editor. Needed by SearchBarEditor.

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

Bases: PySide2.QtWidgets.QStyledItemDelegate

A delegate for the parameter value list tree.

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

Send signal.

setEditorData(self, editor, index)[source]

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

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

Returns editor.

_close_editor(self, editor, index)[source]

Closes editor. Needed by SearchBarEditor.

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

Bases: PySide2.QtWidgets.QStyledItemDelegate

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

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

Send signal.

close_editor(self, editor, index, model)[source]
updateEditorGeometry(self, editor, option, index)[source]
connect_editor_signals(self, editor, index)[source]

Connect editor signals if necessary.

_create_database_editor(self, parent, option, index)[source]
createEditor(self, parent, option, index)[source]

Returns an editor.

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

Bases: ManageItemsDelegate

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

icon_color_editor_requested[source]
createEditor(self, parent, option, index)[source]

Return editor.

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

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

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

Bases: ManageItemsDelegate

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

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

Return editor.

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

Bases: ManageItemsDelegate

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

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

Return editor.

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

Bases: ManageItemsDelegate

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

createEditor(self, 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(self, parent, option, index)[source]

Return editor.