spinetoolbox.spine_db_editor.mvcmodels.single_models

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

Module Contents

Classes

HalfSortedTableModel

Table model for outlining simple tabular data.

SingleModelBase

Base class for all single models that go in a CompoundModelBase subclass.

FilterEntityAlternativeMixin

Provides the interface to filter by entity and alternative.

ParameterMixin

Provides the data method for parameter values and definitions.

EntityMixin

SingleParameterDefinitionModel

A parameter_definition model for a single entity_class.

SingleParameterValueModel

A parameter_value model for a single entity_class.

SingleEntityAlternativeModel

An entity_alternative model for a single entity_class.

class spinetoolbox.spine_db_editor.mvcmodels.single_models.HalfSortedTableModel(parent=None, header=None, lazy=True)[source]

Bases: spinetoolbox.mvcmodels.minimal_table_model.MinimalTableModel

Table model for outlining simple tabular data.

Parameters
  • parent (QObject, optional) – the parent object

  • header (list of str) – header labels

  • lazy (boolean) – if True, fetches data lazily

reset_model(main_data=None)[source]

Reset model.

add_rows(data)[source]
_sort_key(element)[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_models.SingleModelBase(parent, db_map, entity_class_id, committed, lazy=False)[source]

Bases: HalfSortedTableModel

Base class for all single models that go in a CompoundModelBase subclass.

Parameters
  • parent (CompoundModelBase) – the parent model

  • db_map (DatabaseMapping) –

  • entity_class_id (int) –

  • committed (bool) –

abstract property item_type[source]

The DB item type, required by the data method.

property field_map[source]
abstract property _references[source]
property entity_class_name[source]
property dimension_id_list[source]
property fixed_fields[source]
property group_fields[source]
property can_be_filtered[source]
__lt__(other)[source]
update_items_in_db(items)[source]

Update items in db. Required by batch_set_data

_mapped_field(field)[source]
item_id(row)[source]

Returns parameter id for row.

Parameters

row (int) – row index

Returns

parameter id

Return type

int

item_ids()[source]

Returns model’s parameter ids.

Returns

ids

Return type

set of int

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

Make fixed indexes non-editable.

_filter_accepts_row(row)[source]
filter_accepts_item(item)[source]
set_auto_filter(field, values)[source]
_auto_filter_accepts_item(item)[source]

Returns the result of the auto filter.

accepted_rows()[source]

Yields accepted rows, for convenience.

_get_ref(db_item, field)[source]

Returns the item referred by the given field.

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

Returns the data stored under the given role for the item referred to by the index.

Parameters
  • index (QModelIndex) – Index of item

  • role (int) – Data role

Returns

Item data for given role.

batch_set_data(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.

class spinetoolbox.spine_db_editor.mvcmodels.single_models.FilterEntityAlternativeMixin(*args, **kwargs)[source]

Provides the interface to filter by entity and alternative.

set_filter_entity_ids(db_map_class_entity_ids)[source]
set_filter_alternative_ids(db_map_alternative_ids)[source]
filter_accepts_item(item)[source]

Reimplemented to also account for the entity and alternative filter.

_entity_filter_accepts_item(item)[source]

Returns the result of the entity filter.

_alternative_filter_accepts_item(item)[source]

Returns the result of the alternative filter.

class spinetoolbox.spine_db_editor.mvcmodels.single_models.ParameterMixin[source]

Provides the data method for parameter values and definitions.

property value_field[source]
property parameter_definition_id_key[source]
property _references[source]
data(index, role=Qt.ItemDataRole.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.

class spinetoolbox.spine_db_editor.mvcmodels.single_models.EntityMixin[source]
update_items_in_db(items)[source]

Overriden to create entities on the fly first.

abstract _do_update_items_in_db(db_map_data)[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_models.SingleParameterDefinitionModel(parent, db_map, entity_class_id, committed, lazy=False)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.SplitValueAndTypeMixin, ParameterMixin, SingleModelBase

A parameter_definition model for a single entity_class.

Parameters
  • parent (CompoundModelBase) – the parent model

  • db_map (DatabaseMapping) –

  • entity_class_id (int) –

  • committed (bool) –

property item_type[source]

The DB item type, required by the data method.

_sort_key(element)[source]
_do_update_items_in_db(db_map_data)[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_models.SingleParameterValueModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.MakeEntityOnTheFlyMixin, spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.SplitValueAndTypeMixin, ParameterMixin, EntityMixin, FilterEntityAlternativeMixin, SingleModelBase

A parameter_value model for a single entity_class.

property item_type[source]

The DB item type, required by the data method.

_sort_key(element)[source]
_do_update_items_in_db(db_map_data)[source]
class spinetoolbox.spine_db_editor.mvcmodels.single_models.SingleEntityAlternativeModel(*args, **kwargs)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.MakeEntityOnTheFlyMixin, EntityMixin, FilterEntityAlternativeMixin, SingleModelBase

An entity_alternative model for a single entity_class.

property item_type[source]

The DB item type, required by the data method.

property _references[source]
_sort_key(element)[source]
_do_update_items_in_db(db_map_data)[source]