spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models

Single models for parameter definitions and values (as ‘for a single entity’).

authors:
  1. Marin (KTH)
date:

28.6.2019

Module Contents

Classes

SingleParameterModel A parameter model for a single entity_class to go in a CompoundParameterModel.
SingleObjectParameterMixin Associates a parameter model with a single object_class.
SingleRelationshipParameterMixin Associates a parameter model with a single relationship_class.
SingleParameterDefinitionMixin A parameter_definition model for a single entity_class.
SingleParameterValueMixin A parameter_value model for a single entity_class.
SingleObjectParameterDefinitionModel An object parameter_definition model for a single object_class.
SingleRelationshipParameterDefinitionModel A relationship parameter_definition model for a single relationship_class.
SingleObjectParameterValueModel An object parameter_value model for a single object_class.
SingleRelationshipParameterValueModel A relationship parameter_value model for a single relationship_class.
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterModel(header, db_mngr, db_map, entity_class_id, lazy=False)[source]

Bases: spinetoolbox.mvcmodels.minimal_table_model.MinimalTableModel

A parameter model for a single entity_class to go in a CompoundParameterModel. Provides methods to associate the model to an entity_class as well as to filter entities within the class.

Init class.

Parameters:header (list) – list of field names for the header
item_type[source]

The item type, either ‘parameter_value’ or ‘parameter_definition’, required by the data method.

entity_class_type[source]

The entity_class type, either ‘object_class’ or ‘relationship_class’.

json_fields[source]
fixed_fields[source]
group_fields[source]
parameter_definition_id_key[source]
can_be_filtered[source]
insertRows(self, row, count, parent=QModelIndex())[source]

This model doesn’t support row insertion.

item_id(self, row)[source]
db_item(self, index)[source]
_db_item(self, row)[source]
db_item_from_id(self, id_)[source]
db_items(self)[source]
flags(self, index)[source]

Make fixed indexes non-editable.

get_field_item_data(self, field)[source]

Returns item data for given field.

Parameters:field (str) – A field from the header
Returns:str, str
get_id_key(self, field)[source]
get_field_item(self, field, db_item)[source]

Returns a db item corresponding to the given field from the table header, or an empty dict if the field doesn’t contain db items.

data(self, index, role=Qt.DisplayRole)[source]

Gets the id and database for the row, and reads data from the db manager using the item_type property. Paint the object_class icon next to the name. Also paint background of fixed indexes gray and apply custom format to JSON fields.

batch_set_data(self, indexes, data)[source]

Sets data for indexes in batch. Sets data directly in database using db mngr. If successful, updated data will be automatically seen by the data method.

update_items_in_db(self, items)[source]

Update items in db. Required by batch_set_data

_filter_accepts_row(self, row)[source]
_parameter_filter_accepts_row(self, row)[source]

Returns the result of the parameter filter.

_auto_filter_accepts_row(self, row)[source]

Returns the result of the auto filter.

accepted_rows(self)[source]

Returns a list of accepted rows, for convenience.

_get_field_item(self, field, id_)[source]

Returns a item from the db_mngr.get_item depending on the field. If a field doesn’t correspond to a item in the database then an empty dict is returned.

class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleObjectParameterMixin[source]

Associates a parameter model with a single object_class.

entity_class_type[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterMixin[source]

Associates a parameter model with a single relationship_class.

entity_class_type[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterDefinitionMixin(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInParameterNameMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInValueListIdMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.MakeParameterTagMixin

A parameter_definition model for a single entity_class.

Initializes lookup dicts.

item_type[source]
update_items_in_db(self, items)[source]

Update items in db.

Parameters:item (list) – dictionary-items
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterValueMixin(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixin

A parameter_value model for a single entity_class.

Initialize self. See help(type(self)) for accurate signature.

item_type[source]
_filter_accepts_row(self, row)[source]

Reimplemented to also account for the entity filter.

_entity_filter_accepts_row(self, row)[source]

Returns the result of the entity filter.

_alternative_filter_accepts_row(self, row)[source]

Returns the result of the alternative filter.

update_items_in_db(self, items)[source]

Update items in db.

Parameters:item (list) – dictionary-items
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleObjectParameterDefinitionModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleObjectParameterMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterDefinitionMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterModel

An object parameter_definition model for a single object_class.

Initializes lookup dicts.

class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterDefinitionModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterDefinitionMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterModel

A relationship parameter_definition model for a single relationship_class.

Initializes lookup dicts.

class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleObjectParameterValueModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleObjectParameterMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterValueMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterModel

An object parameter_value model for a single object_class.

Initialize self. See help(type(self)) for accurate signature.

class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterValueModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterValueMixin, spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleParameterModel

A relationship parameter_value model for a single relationship_class.

Initialize self. See help(type(self)) for accurate signature.