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

property item_type(self)[source]

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

property entity_class_type(self)[source]

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

property entity_class_name_field(self)[source]
property entity_class_name(self)[source]
property entity_class_id_key(self)[source]
property json_fields(self)[source]
property fixed_fields(self)[source]
property group_fields(self)[source]
property parameter_definition_id_key(self)[source]
property can_be_filtered(self)[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.

abstract update_items_in_db(self, items)[source]

Update items in db. Required by batch_set_data

set_filter_parameter_ids(self, parameter_ids)[source]
_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.

property entity_class_type(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_parameter_models.SingleRelationshipParameterMixin[source]

Associates a parameter model with a single relationship_class.

property entity_class_type(self)[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.

property item_type(self)[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.ValidateValueInListForUpdateMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInAlternativeIdMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ImposeEntityClassIdMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInParameterDefinitionIdsMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInEntityIdsMixin

A parameter_value model for a single entity_class.

Initializes lookup dicts.

property item_type(self)[source]
property entity_type(self)[source]

Either ‘object’ or “relationship’.

property entity_id_key(self)[source]
property entity_name_key(self)[source]
property entity_name_key_in_cache(self)[source]
set_filter_entity_ids(self, db_map_class_entity_ids)[source]
set_filter_alternative_ids(self, db_map_alternative_ids)[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

_check_item(self, item)[source]

Checks if a db item is good to be updated.

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

Bases: SingleObjectParameterMixin, SingleParameterDefinitionMixin, 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: SingleRelationshipParameterMixin, SingleParameterDefinitionMixin, 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: SingleObjectParameterMixin, SingleParameterValueMixin, SingleParameterModel

An object parameter_value model for a single object_class.

Initializes lookup dicts.

property entity_type(self)[source]

Either ‘object’ or “relationship’.

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

Bases: SingleRelationshipParameterMixin, spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.MakeRelationshipOnTheFlyMixin, SingleParameterValueMixin, SingleParameterModel

A relationship parameter_value model for a single relationship_class.

Initializes lookup dicts.

property entity_type(self)[source]

Either ‘object’ or “relationship’.

update_items_in_db(self, items)[source]

Update items in db.

Parameters

item (list) – dictionary-items