spinetoolbox.mvcmodels.compound_table_model
¶
Models that vertically concatenate two or more table models.
- authors
Marin (KTH)
- date
9.10.2019
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) – the parent object
- map_to_sub(self, 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(self, 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
- item_at_row(self, row)[source]¶
Returns the item at given row.
- Parameters
row (int) –
- Returns
object
- sub_model_at_row(self, row)[source]¶
Returns the submodel corresponding to the given row in the compound model.
- Parameters
row (int) –
- Returns
MinimalTableModel
- _append_row_map(self, row_map)[source]¶
Appends given row map to the tail of the model.
- Parameters
row_map (list) – tuples (model, row number)
- static _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(self, parent=QModelIndex())[source]¶
Returns True if any of the submodels that haven’t been fetched yet can fetch more.
- fetchMore(self, parent=QModelIndex())[source]¶
Fetches the next sub model and increments the fetched counter.
- data(self, index, role=Qt.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(self, 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) – the parent object
- init_model(self)[source]¶
Initializes the compound model. Basically populates the sub_models list attribute with the result of _create_single_models and _create_empty_model.
- connect_model_signals(self)[source]¶
Connects signals so changes in the submodels are acknowledge by the compound.
- _recompute_empty_row_map(self)[source]¶
Recomputeds the part of the row map corresponding to the empty model.
- _handle_empty_rows_removed(self, parent, empty_first, empty_last)[source]¶
Runs when rows are removed from the empty model. Updates row_map, then emits rowsRemoved so the removed rows are no longer visible.
- _handle_empty_rows_inserted(self, parent, empty_first, empty_last)[source]¶
Runs when rows are inserted to the empty model. Updates row_map, then emits rowsInserted so the new rows become visible.
- _handle_single_model_reset(self, single_model)[source]¶
Runs when one of the single models is reset. Updates row_map, then emits rowsInserted so the new rows become visible.