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

class spinetoolbox.mvcmodels.single_parameter_models.SingleParameterModel(parent, header, db_mngr, db_map, entity_class_id, lazy=True)[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:
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.

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.

fetchMore(self, parent=None)[source]

Fetch data and use it to reset the model.

_fetch_data(self)[source]

Returns data to reset the model with and call it fetched. Reimplement in subclasses if you want to populate your model automatically.

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]
_main_filter_accepts_row(self, row)[source]

Applies the main filter, defined by the selections in the grand parent.

_auto_filter_accepts_row(self, row)[source]

Applies the autofilter, defined by the autofilter drop down menu.

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.mvcmodels.single_parameter_models.SingleObjectParameterMixin[source]

Associates a parameter model with a single object class.

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

Associates a parameter model with a single relationship class.

entity_class_type[source]
class spinetoolbox.mvcmodels.single_parameter_models.SingleParameterDefinitionMixin[source]

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

A parameter definition model for a single entity class.

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

Update items in db.

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

Bases: spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin

A parameter value model for a single entity class.

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

Reimplemented to filter objects.

update_items_in_db(self, items)[source]

Update items in db.

Parameters:item (list) – dictionary-items
class spinetoolbox.mvcmodels.single_parameter_models.SingleObjectParameterDefinitionModel[source]

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

An object parameter definition model for a single object class.

_fetch_data(self)[source]

Returns object parameter definition ids.

class spinetoolbox.mvcmodels.single_parameter_models.SingleRelationshipParameterDefinitionModel[source]

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

A relationship parameter definition model for a single relationship class.

_fetch_data(self)[source]

Returns relationship parameter definition ids.

class spinetoolbox.mvcmodels.single_parameter_models.SingleObjectParameterValueModel[source]

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

An object parameter value model for a single object class.

_fetch_data(self)[source]

Returns object parameter value ids.

class spinetoolbox.mvcmodels.single_parameter_models.SingleRelationshipParameterValueModel[source]

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

A relationship parameter value model for a single relationship class.

_fetch_data(self)[source]

Returns relationship parameter value ids.