spinetoolbox.mvcmodels.minimal_table_model

Contains a minimal table model.

authors:
  1. Marin (KTH)
date:

20.5.2018

Module Contents

class spinetoolbox.mvcmodels.minimal_table_model.MinimalTableModel(parent=None, header=None, lazy=True)[source]

Bases: PySide2.QtCore.QAbstractTableModel

Table model for outlining simple tabular data.

Parameters:parent (QObject) – the parent object
clear(self)[source]

Clear all data in model.

flags(self, index)[source]

Return index flags.

canFetchMore(self, parent=None)[source]

Return True if the model hasn’t been fetched.

fetchMore(self, parent=None)[source]

Fetch data and use it to reset the model.

rowCount(self, parent=QModelIndex())[source]

Number of rows in the model.

columnCount(self, parent=QModelIndex())[source]

Number of columns in the model.

headerData(self, section, orientation=Qt.Horizontal, role=Qt.DisplayRole)[source]

Returns headers.

set_horizontal_header_labels(self, labels)[source]

Set horizontal header labels.

insert_horizontal_header_labels(self, section, labels)[source]

Insert horizontal header labels at the given section.

horizontal_header_labels(self)[source]
setHeaderData(self, section, orientation, value, role=Qt.EditRole)[source]

Sets the data for the given role and section in the header with the specified orientation to the value supplied.

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.

row_data(self, row, role=Qt.DisplayRole)[source]

Returns the data stored under the given role for the given row.

Parameters:
  • row (int) – Item row
  • role (int) – Data role
Returns:

Row data for given role.

setData(self, index, value, role=Qt.EditRole)[source]

Set data in model.

batch_set_data(self, indexes, data)[source]

Batch set data for indexes.

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

Inserts count rows into the model before the given row. Items in the new row will be children of the item represented by the parent model index.

Parameters:
  • row (int) – Row number where new rows are inserted
  • count (int) – Number of inserted rows
  • parent (QModelIndex) – Parent index
Returns:

True if rows were inserted successfully, False otherwise

insertColumns(self, column, count, parent=QModelIndex())[source]

Inserts count columns into the model before the given column. Items in the new column will be children of the item represented by the parent model index.

Parameters:
  • column (int) – Column number where new columns are inserted
  • count (int) – Number of inserted columns
  • parent (QModelIndex) – Parent index
Returns:

True if columns were inserted successfully, False otherwise

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

Removes count rows starting with the given row under parent.

Parameters:
  • row (int) – Row number where to start removing rows
  • count (int) – Number of removed rows
  • parent (QModelIndex) – Parent index
Returns:

True if rows were removed successfully, False otherwise

removeColumns(self, column, count, parent=QModelIndex())[source]

Removes count columns starting with the given column under parent.

Parameters:
  • column (int) – Column number where to start removing columns
  • count (int) – Number of removed columns
  • parent (QModelIndex) – Parent index
Returns:

True if columns were removed successfully, False otherwise

reset_model(self, main_data=None)[source]

Reset model.