spinetoolbox.mvcmodels.array_model

Contains model for the Array editor widget.

Module Contents

Classes

ArrayModel

Model for the Array parameter_value type.

class spinetoolbox.mvcmodels.array_model.ArrayModel(parent)[source]

Bases: PySide6.QtCore.QAbstractTableModel

Model for the Array parameter_value type.

Even if the array is empty this model’s rowCount() will still return 1. This is to show an empty row in the table view.

Parameters

parent (QObject) – parent object

array()[source]

Returns the array modeled by this model.

batch_set_data(indexes, values)[source]

Sets data at multiple indexes at once.

Parameters
  • indexes (list of QModelIndex) – indexes to set

  • values (list of str) – values corresponding to the indexes

columnCount(parent=QModelIndex())[source]

Returns 2.

_convert_to_data_type(indexes, values)[source]

Converts values from string to current data type filtering failed conversions.

Parameters
  • indexes (list of QModelIndex) – indexes

  • values (list of str) – values to convert

Returns

indexes and converted values

Return type

tuple

data(index, role=Qt.ItemDataRole.DisplayRole)[source]

Returns model’s data for given role.

flags(index)[source]

Returns table cell’s flags.

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

Returns header data.

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

Inserts rows to the array.

is_expanse_row(row)[source]

Returns True if row is the expanse row.

Parameters

row (int) – a row

Returns

True is row is expanse row, False otherwise

Return type

bool

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

Removes rows from the array.

reset(value)[source]

Resets the model to a new array.

Parameters

value (Array) – a new array to model

rowCount(parent=QModelIndex())[source]

Returns the length of the array.

Note: returns 1 even if the array is empty.

set_array_type(new_type)[source]

Changes the data type of array’s elements.

Parameters

new_type (Type) – new element type

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

Sets the value at given index.