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: |
|
|---|---|
| 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.CompoundWithEmptyTableModelA 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.
-
entity_class_type[source]¶ Returns the entity_class type, either ‘object_class’ or ‘relationship_class’.
Returns: str
-
item_type[source]¶ Returns the parameter item type, either ‘parameter_definition’ or ‘parameter_value’.
Returns: str
-
_single_model_type[source]¶ Returns a constructor for the single models.
Returns: SingleParameterModel
-
entity_class_id_key[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
-
static
_settattr_if_different(obj, attr, val)[source]¶ Sets the given attribute of the given object to the given value if it’s different from the one currently stored. Used for updating filters.
Returns: True if the attributed was set, False otherwise Return type: bool
-
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 removed 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:
spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterDefinitionMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterModelA 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:
spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterDefinitionMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterModelA 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:
spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundObjectParameterMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterValueMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterModelA 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:
spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundRelationshipParameterMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterValueMixin,spinetoolbox.spine_db_editor.mvcmodels.compound_parameter_models.CompoundParameterModelA 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