spinetoolbox.mvcmodels.minimal_table_model

Contains a minimal table model.

Module Contents

Classes

MinimalTableModel

Table model for outlining simple tabular data.

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

Bases: PySide6.QtCore.QAbstractTableModel

Table model for outlining simple tabular data.

Parameters
  • parent (QObject, optional) – the parent object

  • header (list of str) – header labels

  • lazy (boolean) – if True, fetches data lazily

clear()[source]

Clear all data in model.

flags(index)[source]

Return index flags.

canFetchMore(parent)[source]

Return True if the model hasn’t been fetched.

fetchMore(parent)[source]

Fetch data and use it to reset the model.

rowCount(parent=QModelIndex())[source]

Number of rows in the model.

columnCount(parent=QModelIndex())[source]

Number of columns in the model.

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

Returns headers.

set_horizontal_header_labels(labels)[source]

Set horizontal header labels.

insert_horizontal_header_labels(section, labels)[source]

Insert horizontal header labels at the given section.

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

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

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.

row_data(row, role=Qt.ItemDataRole.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(index, value, role=Qt.ItemDataRole.EditRole)[source]

Set data in model.

batch_set_data(indexes, data)[source]

Batch set data for indexes.

Parameters
  • indexes (Iterable of QModelIndex) – model indexes

  • data (Iterable) – data at each index

Returns

True if data was set successfully, False otherwise

Return type

boolean

insertRows(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(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(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(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(main_data=None)[source]

Reset model.