spinetoolbox.spine_db_editor.mvcmodels.compound_models
Compound models. These models concatenate several ‘single’ models and one ‘empty’ model.
Module Contents
Classes
A base model for all models that show data in stacked format. |
|
Provides the interface to filter by entity and alternative. |
|
Provides the interface to edit values via ParameterValueEditor. |
|
A model that concatenates several single parameter_definition models and one empty parameter_definition model. |
|
A model that concatenates several single parameter_value models and one empty parameter_value model. |
|
Provides the interface to filter by entity and alternative. |
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.CompoundModelBase(parent, db_mngr, *db_maps)[source]
Bases:
spinetoolbox.mvcmodels.compound_table_model.CompoundWithEmptyTableModel
A base model for all models that show data in stacked format.
- Parameters
parent (SpineDBEditor) – the parent object
db_mngr (SpineDBManager) – the database manager
*db_maps (DatabaseMapping) – the database maps included in the model
- abstract property _single_model_type[source]
Returns a constructor for the single models.
- Returns
SingleParameterModel
- abstract property _empty_model_type[source]
Returns a constructor for the empty model.
- Returns
EmptyParameterModel
- canFetchMore(_parent)[source]
Returns True if any of the submodels that haven’t been fetched yet can fetch more.
Returns auto filter menu for given logical index from header view.
- Parameters
logical_index (int) –
- Returns
AutoFilterMenu
- headerData(section, orientation=Qt.Orientation.Horizontal, role=Qt.ItemDataRole.DisplayRole)[source]
Returns an italic font in case the given column has an autofilter installed.
- _create_empty_model()[source]
Returns the empty model for this compound model.
- Returns
EmptyParameterModel
- filter_accepts_model(model)[source]
Returns a boolean indicating whether the given model passes the filter for compound model.
- Parameters
model (SingleModelBase or EmptyModelBase) –
- Returns
bool
- accepted_single_models()[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(field, values)[source]
Updates and applies the auto filter.
- Parameters
field (str) – the field name
values (dict) – mapping (db_map, entity_class_id) to set of valid values
- _set_compound_auto_filter(field, values)[source]
Sets the auto filter for given column in the compound model.
- Parameters
field (str) – the field name
values (set) – set of valid (db_map, item_type, id) tuples
- _set_single_auto_filter(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_iterator_for_model(model)[source]
Yields row map for the given model. Reimplemented to take filter status into account.
- Parameters
model (SingleParameterModel, EmptyParameterModel) –
- Yields
tuple – (model, row number) for each accepted row
- _models_with_db_map(db_map)[source]
Returns a collection of single models with given db_map.
- Parameters
db_map (DatabaseMapping) –
- Returns
list
- static _items_per_class(items)[source]
Returns a dict mapping entity_class ids to a set of items.
- Parameters
items (list) –
- Returns
dict
- handle_items_added(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 DatabaseMapping
- _add_items(db_map, entity_class_id, ids, committed)[source]
Creates new single model and resets it with the given parameter ids.
- Parameters
db_map (DatabaseMapping) – database map
entity_class_id (int) – parameter’s entity class id
ids (list of int) – parameter ids
committed (bool) – True if the ids have been committed, False otherwise
- handle_items_updated(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 DatabaseMapping
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.FilterEntityAlternativeMixin(*args, **kwargs)[source]
Provides the interface to filter by entity and alternative.
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.EditParameterValueMixin[source]
Provides the interface to edit values via ParameterValueEditor.
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.CompoundParameterDefinitionModel(parent, db_mngr, *db_maps)[source]
Bases:
EditParameterValueMixin
,CompoundModelBase
A model that concatenates several single parameter_definition models and one empty parameter_definition model.
- Parameters
parent (SpineDBEditor) – the parent object
db_mngr (SpineDBManager) – the database manager
*db_maps (DatabaseMapping) – the database maps included in the model
- property _single_model_type[source]
Returns a constructor for the single models.
- Returns
SingleParameterModel
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.CompoundParameterValueModel(*args, **kwargs)[source]
Bases:
FilterEntityAlternativeMixin
,EditParameterValueMixin
,CompoundModelBase
A model that concatenates several single parameter_value models and one empty parameter_value model.
- property _single_model_type[source]
Returns a constructor for the single models.
- Returns
SingleParameterModel
- class spinetoolbox.spine_db_editor.mvcmodels.compound_models.CompoundEntityAlternativeModel(*args, **kwargs)[source]
Bases:
FilterEntityAlternativeMixin
,CompoundModelBase
Provides the interface to filter by entity and alternative.
- property _single_model_type[source]
Returns a constructor for the single models.
- Returns
SingleParameterModel