spinetoolbox.mvcmodels.time_pattern_model

A model for time patterns, used by the parameter value editors.

authors:
  1. Soininen (VTT)
date:

4.7.2019

Module Contents

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

Bases: spinetoolbox.mvcmodels.indexed_value_table_model.IndexedValueTableModel

A model for time pattern type parameter values.

Parameters:value (TimePattern) – a time pattern value
flags(self, index)[source]

Returns flags at index.

insertRows(self, 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

removeRows(self, 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

setData(self, index, value, role=Qt.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

batch_set_data(self, 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