spinetoolbox.mvcmodels.time_pattern_model

A model for time patterns, used by the parameter_value editors.

Module Contents

Classes

TimePatternModel

A model for time pattern type parameter values.

class spinetoolbox.mvcmodels.time_pattern_model.TimePatternModel(value, parent)[source]

Bases: spinetoolbox.mvcmodels.indexed_value_table_model.IndexedValueTableModel

A model for time pattern type parameter values.

Parameters
  • value (IndexedValue) – a parameter_value

  • parent (QObject) – parent object

flags(index)[source]

Returns flags at index.

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

Inserts new time period - value pairs into the pattern.

New time periods are initialized to empty strings and the corresponding values to zeros.

Parameters
  • row (int) – an index where to insert the new data

  • count (int) – number of time period - value pairs to insert

  • parent (QModelIndex) – an index to a parent model

Returns

True if the operation was successful

Return type

bool

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

Removes time period - value pairs from the pattern.

Parameters
  • row (int) – an index where to remove the data

  • count (int) – number of time period - value pairs to remove

  • parent (QModelIndex) – an index to a parent model

Returns

True if the operation was successful

Return type

bool

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

Sets a time period or a value in the pattern.

Column index 0 corresponds to the time periods while 1 corresponds to the values.

Parameters
  • index (QModelIndex) – an index to the model

  • value (str, float) – a new time period or value

  • role (int) – a role

Returns

True if the operation was successful

Return type

bool

batch_set_data(indexes, values)[source]

Sets data for several indexes at once.

Parameters
  • indexes (Sequence) – a sequence of model indexes

  • values (Sequence) – a sequence of time periods/floats corresponding to the indexes