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
Marin (KTH)
- date
28.6.2019
Module Contents¶
Classes¶
A model that concatenates several single parameter models |
|
Implements the interface for populating and filtering a compound object parameter model. |
|
Implements the interface for populating and filtering a compound relationship parameter model. |
|
Handles signals from db mngr for parameter_definition models. |
|
Handles signals from db mngr for parameter_value models. |
|
A model that concatenates several single object parameter_definition models |
|
A model that concatenates several single relationship parameter_definition models |
|
A model that concatenates several single object parameter_value models |
|
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.
- 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
Makes auto filter menus.
Returns auto filter menu for given logical index from header view.
- Parameters
logical_index (int) –
- Returns
ParameterViewFilterMenu
Modifies data in filter menus.
- Parameters
action (str) – either ‘add’, ‘remove’, or ‘update’
db_map (DiffDatabaseMapping) –
db_items (list(dict)) –
- 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
- 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
- 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
model (SingleParameterModel) – the model
field (str) – the field name
- 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
- 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
- class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterMixin[source]¶
Implements the interface for populating and filtering a compound object parameter model.
- class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterMixin[source]¶
Implements the interface for populating and filtering a compound relationship parameter model.
- class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterDefinitionMixin[source]¶
Handles signals from db mngr for parameter_definition models.
- class spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterValueMixin[source]¶
Handles signals from db mngr for parameter_value models.
- 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
- 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
- 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
- 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