spinetoolbox.mvcmodels.compound_table_model

Models that vertically concatenate two or more table models.

authors:
  1. Marin (KTH)
date:

9.10.2019

Module Contents

class spinetoolbox.mvcmodels.compound_table_model.CompoundTableModel(parent, 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
refresh(self)[source]

Refreshes the layout by computing a new row map.

do_refresh(self)[source]

Recomputes the row and inverse row maps.

_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.

flags(self, index)[source]
data(self, index, role=Qt.DisplayRole)[source]
rowCount(self, parent=QModelIndex())[source]

Returns the sum of rows in all models.

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.

insertRows(self, row, count, parent=QModelIndex())[source]

Insert count rows after the given row under the given parent. Localizes the appropriate submodel and calls insertRows on it.

class spinetoolbox.mvcmodels.compound_table_model.CompoundWithEmptyTableModel[source]

Bases: spinetoolbox.mvcmodels.compound_table_model.CompoundTableModel

A compound parameter table model where the last model is an empty row model.

single_models[source]
empty_model[source]
_create_single_models(self)[source]

Returns a list of single models.

_create_empty_model(self)[source]

Returns an empty model.

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.

_insert_single_row_map(self, single_row_map)[source]

Inserts given row map just before the empty model’s.

clear_model(self)[source]

Clears the model.