spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models

Compound models for object parameter definitions and values. These models concatenate several ‘single’ models and one ‘empty’ model.

authors
  1. Marin (KTH)

date

28.6.2019

Module Contents

Classes

CompoundParameterModel

A model that concatenates several single parameter models

CompoundObjectParameterMixin

Implements the interface for populating and filtering a compound object parameter model.

CompoundRelationshipParameterMixin

Implements the interface for populating and filtering a compound relationship parameter model.

CompoundParameterDefinitionMixin

Handles signals from db mngr for parameter_definition models.

CompoundParameterValueMixin

Handles signals from db mngr for parameter_value models.

CompoundObjectParameterDefinitionModel

A model that concatenates several single object parameter_definition models

CompoundRelationshipParameterDefinitionModel

A model that concatenates several single relationship parameter_definition models

CompoundObjectParameterValueModel

A model that concatenates several single object parameter_value models

CompoundRelationshipParameterValueModel

A model that concatenates several single relationship parameter_value models

class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterModel(parent, db_mngr, *db_maps)[source]

Bases: spinetoolbox.mvcmodels.compound_table_model.CompoundWithEmptyTableModel

A model that concatenates several single parameter models and one empty parameter model.

Initializes model.

Parameters
  • parent (SpineDBEditor) – the parent object

  • db_mngr (SpineDBManager) – the database manager

  • *db_maps (DiffDatabaseMapping) – the database maps included in the model

data_for_single_model_received[source]

Emitted by the fetcher when there’s data for another single model.

abstract _make_header(self)[source]
property entity_class_type(self)[source]

Returns the entity_class type, either ‘object_class’ or ‘relationship_class’.

Returns

str

property item_type(self)[source]

Returns the parameter item type, either ‘parameter_definition’ or ‘parameter_value’.

Returns

str

property _single_model_type(self)[source]

Returns a constructor for the single models.

Returns

SingleParameterModel

property _empty_model_type(self)[source]

Returns a constructor for the empty model.

Returns

EmptyParameterModel

property entity_class_id_key(self)[source]

Returns the key corresponding to the entity_class id (either “object_class_id” or “relationship_class_id”)

Returns

str

property parameter_definition_id_key(self)[source]
init_model(self)[source]

Initializes the model.

_make_auto_filter_menus(self)[source]

Makes auto filter menus.

get_auto_filter_menu(self, logical_index)[source]

Returns auto filter menu for given logical index from header view.

Parameters

logical_index (int) –

Returns

ParameterViewFilterMenu

_modify_data_in_filter_menus(self, action, db_map, db_items)[source]

Modifies data in filter menus.

Parameters
  • action (str) – either ‘add’, ‘remove’, or ‘update’

  • db_map (DiffDatabaseMapping) –

  • db_items (list(dict)) –

_do_add_data_to_filter_menus(self, db_map, db_items)[source]
_do_update_data_in_filter_menus(self, db_map, db_items)[source]
_do_remove_data_from_filter_menus(self, db_map, db_items)[source]
headerData(self, section, orientation=Qt.Horizontal, role=Qt.DisplayRole)[source]

Returns an italic font in case the given column has an autofilter installed.

_create_single_models(self)[source]

Returns a list of single models for this compound model, one for each entity_class in each database.

Returns

list

_create_empty_model(self)[source]

Returns the empty model for this compound model.

Returns

EmptyParameterModel

filter_accepts_model(self, model)[source]

Returns a boolean indicating whether or not the given model passes the filter for compound model.

Parameters

model (SingleParameterModel, EmptyParameterModel) –

Returns

bool

_class_filter_accepts_model(self, model)[source]
_auto_filter_accepts_model(self, model)[source]
accepted_single_models(self)[source]

Returns a list of accepted single models by calling filter_accepts_model on each of them, just for convenience.

Returns

list

_invalidate_filter(self)[source]

Sets the filter invalid.

_refresh_if_still_invalid(self)[source]
set_filter_class_ids(self, class_ids)[source]
set_filter_parameter_ids(self, parameter_ids)[source]
set_auto_filter(self, field, auto_filter)[source]

Updates and applies the auto filter.

Parameters
  • field (str) – the field name

  • auto_filter (dict) – mapping db_map to entity_class id to accepted values for the field

set_compound_auto_filter(self, field, auto_filter)[source]

Sets the auto filter for given column in the compound model.

Parameters
  • field (str) – the field name

  • auto_filter (dict) – maps tuple (database map, entity_class id) to list of accepted ids for the field

set_single_auto_filter(self, model, field)[source]

Sets the auto filter for given column in the given single model.

Parameters
Returns

True if the auto-filtered values were updated, None otherwise

Return type

bool

_row_map_for_model(self, model)[source]

Returns the row map for the given model. Reimplemented to take filter status into account.

Parameters

model (SingleParameterModel, EmptyParameterModel) –

Returns

tuples (model, row number) for each accepted row

Return type

list

_models_with_db_map(self, db_map)[source]

Returns a collection of single models with given db_map.

Parameters

db_map (DiffDatabaseMapping) –

Returns

list

receive_entity_classes_removed(self, db_map_data)[source]

Runs when entity classes are removed from the dbs. Removes sub-models for the given entity classes and dbs.

Parameters

db_map_data (dict) – list of removed dict-items keyed by DiffDatabaseMapping

_items_per_class(self, items)[source]

Returns a dict mapping entity_class ids to a set of items.

Parameters

items (list) –

Returns

dict

receive_parameter_data_added(self, db_map_data)[source]

Runs when either parameter definitions or values are added to the dbs. Adds necessary sub-models and initializes them with data. Also notifies the empty model so it can remove rows that are already in.

Parameters

db_map_data (dict) – list of added dict-items keyed by DiffDatabaseMapping

create_and_append_single_model(self, db_map, entity_class_id, ids)[source]
receive_parameter_data_updated(self, db_map_data)[source]

Runs when either parameter definitions or values are updated in the dbs. Emits dataChanged so the parameter_name column is refreshed.

Parameters

db_map_data (dict) – list of updated dict-items keyed by DiffDatabaseMapping

receive_parameter_data_removed(self, db_map_data)[source]

Runs when either parameter definitions or values are removed from the dbs. Removes the affected rows from the corresponding single models.

Parameters

db_map_data (dict) – list of removed dict-items keyed by DiffDatabaseMapping

_emit_data_changed_for_column(self, field)[source]

Lazily emits data changed for an entire column.

Parameters

field (str) – the column header

db_item(self, index)[source]
db_map_id(self, index)[source]
index_name(self, index)[source]
get_set_data_delayed(self, index)[source]

Returns a function that ParameterValueEditor can call to set data for the given index at any later time, even if the model changes.

Parameters

index (QModelIndex) –

Returns

function

get_entity_class_id(self, index, db_map)[source]
filter_by(self, rows_per_column)[source]
filter_excluding(self, rows_per_column)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterMixin[source]

Implements the interface for populating and filtering a compound object parameter model.

property entity_class_type(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterMixin[source]

Implements the interface for populating and filtering a compound relationship parameter model.

property entity_class_type(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterDefinitionMixin[source]

Handles signals from db mngr for parameter_definition models.

property item_type(self)[source]
receive_parameter_definition_tags_set(self, db_map_data)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterValueMixin[source]

Handles signals from db mngr for parameter_value models.

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

Returns the entity type, either ‘object’ or ‘relationship’ Used by update_single_main_filter.

Returns

str

set_filter_entity_ids(self, entity_ids)[source]
set_filter_alternative_ids(self, alternative_ids)[source]
receive_alternatives_updated(self, db_map_data)[source]

Updated alternative column

Parameters

db_map_data (dict) – list of updated dict-items keyed by DiffDatabaseMapping

class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterDefinitionModel(parent, db_mngr, *db_maps)[source]

Bases: CompoundObjectParameterMixin, CompoundParameterDefinitionMixin, CompoundParameterModel

A model that concatenates several single object parameter_definition models and one empty object parameter_definition model.

Initializes model.

Parameters
  • parent (SpineDBEditor) – the parent object

  • db_mngr (SpineDBManager) – the database manager

  • *db_maps (DiffDatabaseMapping) – the database maps included in the model

_make_header(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterDefinitionModel(parent, db_mngr, *db_maps)[source]

Bases: CompoundRelationshipParameterMixin, CompoundParameterDefinitionMixin, CompoundParameterModel

A model that concatenates several single relationship parameter_definition models and one empty relationship parameter_definition model.

Initializes model.

Parameters
  • parent (SpineDBEditor) – the parent object

  • db_mngr (SpineDBManager) – the database manager

  • *db_maps (DiffDatabaseMapping) – the database maps included in the model

_make_header(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterValueModel(parent, db_mngr, *db_maps)[source]

Bases: CompoundObjectParameterMixin, CompoundParameterValueMixin, CompoundParameterModel

A model that concatenates several single object parameter_value models and one empty object parameter_value model.

Initializes model.

Parameters
  • parent (SpineDBEditor) – the parent object

  • db_mngr (SpineDBManager) – the database manager

  • *db_maps (DiffDatabaseMapping) – the database maps included in the model

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

Returns the entity type, either ‘object’ or ‘relationship’ Used by update_single_main_filter.

Returns

str

class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterValueModel(parent, db_mngr, *db_maps)[source]

Bases: CompoundRelationshipParameterMixin, CompoundParameterValueMixin, CompoundParameterModel

A model that concatenates several single relationship parameter_value models and one empty relationship parameter_value model.

Initializes model.

Parameters
  • parent (SpineDBEditor) – the parent object

  • db_mngr (SpineDBManager) – the database manager

  • *db_maps (DiffDatabaseMapping) – the database maps included in the model

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

Returns the entity type, either ‘object’ or ‘relationship’ Used by update_single_main_filter.

Returns

str