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.
_ErrorCell A sentinel class to mark erroneous cells in the table.
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.

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

Returns 1.

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.

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.

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

Sets the value at given index.

_set_data(self, index, value)[source]

Sets data for given index.

In case of errors the value at index is replaced by an _ErrorCell sentinel.

Parameters:
  • index (QModelIndex) – an index
  • value (str) – value in database format
class spinetoolbox.mvcmodels.array_model._ErrorCell(edit_value, tooltip)[source]

A sentinel class to mark erroneous cells in the table.

Parameters:
  • edit_value (str) – the JSON string that caused the error
  • tooltip (str) – tooltip that should be shown on the table cell