spinetoolbox.mvcmodels.array_model

Contains logic for the fixed step time series editor widget.

author
  1. Soininen (VTT)

date

14.6.2019

Module Contents

Classes

ArrayModel

Model for the Array parameter_value type.

class spinetoolbox.mvcmodels.array_model.ArrayModel[source]

Bases: PySide2.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.

array(self)[source]

Returns the array modeled by this model.

batch_set_data(self, 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(self, parent=QModelIndex())[source]

Returns 1.

_convert_to_data_type(self, 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(self, index, role=Qt.DisplayRole)[source]

Returns model’s data for given role.

flags(self, index)[source]

Returns table cell’s flags.

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

Returns header data.

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

Inserts rows to the array.

is_expanse_row(self, 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(self, row, count, parent=QModelIndex())[source]

Removes rows from the array.

reset(self, value)[source]

Resets the model to a new array.

Parameters

value (Array) – a new array to model

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

Returns the length of the array.

Note: returns 1 even if the array is empty.

set_array_type(self, new_type)[source]

Changes the data type of array’s elements.

Parameters

new_type (Type) – new element type

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

Sets the value at given index.