spinetoolbox.mvcmodels.compound_table_model
Models that vertically concatenate two or more table models.
Module Contents
Classes
A model that concatenates several sub table models vertically. |
|
A compound parameter table model where the last model is an empty row model. |
- class spinetoolbox.mvcmodels.compound_table_model.CompoundTableModel(parent=None, header=None)[source]
Bases:
spinetoolbox.mvcmodels.minimal_table_model.MinimalTableModel
A model that concatenates several sub table models vertically.
Initializes model.
- Parameters
parent (QObject, optional) – the parent object
header (list of str, optional) – header labels
- map_to_sub(index)[source]
Returns an equivalent submodel index.
- Parameters
index (QModelIndex) – the compound model index.
- Returns
the equivalent index in one of the submodels
- Return type
QModelIndex
- map_from_sub(sub_model, sub_index)[source]
Returns an equivalent compound model index.
- Parameters
sub_model (MinimalTableModel) – the submodel
sub_index (QModelIndex) – the submodel index.
- Returns
the equivalent index in the compound model
- Return type
QModelIndex
- sub_model_at_row(row)[source]
Returns the submodel corresponding to the given row in the compound model.
- Parameters
row (int) –
- Returns
MinimalTableModel
- sub_model_row(row)[source]
Calculates sub model row.
- Parameters
row (int) – row in compound model
- Returns
row in sub model
- Return type
int
- _append_row_map(row_map)[source]
Appends given row map to the tail of the model.
- Parameters
row_map (list) – tuples (model, row number)
- _row_map_iterator_for_model(model)[source]
Yields row map for given model. The base class implementation just yields all model rows.
- Parameters
model (MinimalTableModel) –
- Yields
tuple – (model, row number)
- _row_map_for_model(model)[source]
Returns row map for given model. The base class implementation just returns all model rows.
- Parameters
model (MinimalTableModel) –
- Returns
tuples (model, row number)
- Return type
list
- canFetchMore(parent)[source]
Returns True if any of the submodels that haven’t been fetched yet can fetch more.
- 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. Distributes indexes and values among the different submodels and calls batch_set_data on each of them.
- class spinetoolbox.mvcmodels.compound_table_model.CompoundWithEmptyTableModel(parent=None, header=None)[source]
Bases:
CompoundTableModel
A compound parameter table model where the last model is an empty row model.
Initializes model.
- Parameters
parent (QObject, optional) – the parent object
header (list of str, optional) – header labels
- abstract _create_empty_model()[source]
Creates and returns an empty model.
- Returns
model
- Return type
- init_model()[source]
Initializes the compound model.
Basically populates the sub_models list attribute with the result of _create_empty_model.
- _connect_single_model(model)[source]
Connects signals so changes in the submodels are acknowledged by the compound.
- _recompute_empty_row_map()[source]
Recomputes the part of the row map corresponding to the empty model.
- _handle_empty_rows_removed(parent, empty_first, empty_last)[source]
Updates row_map when rows are removed from the empty model.