spinetoolbox.mvcmodels.map_model
¶
A model for maps, used by the parameter_value editors.
- authors
Soininen (VTT)
- date
11.2.2020
Module Contents¶
Classes¶
A model for Map type parameter values. |
Functions¶
|
Turns table into nested dictionaries. |
|
Constructs a |
|
Counts the number of non-None elements at the beginning of row. |
- class spinetoolbox.mvcmodels.map_model.MapModel(map_value)[source]¶
Bases:
PySide2.QtCore.QAbstractTableModel
A model for Map type parameter values.
This model represents the Map as a 2D table. Each row consists of one or more index columns and a value column. The last columns of a row are padded with Nones.
Example
Map { "A": 1.0 "B": Map {"a": -1.0} "C": 3.0 }
The table corresponding to the above map:
“A”
1.0
None
“B”
“a”
-1.0
“C”
3.0
None
- Parameters
map_value (Map) – a map
- clear(self, indexes)[source]¶
Clears table cells.
- Parameters
indexes (list of QModelIndex) – indexes to clear
- headerData(self, section, orientation, role=Qt.DisplayRole)[source]¶
Returns row numbers for vertical headers and column titles for horizontal ones.
- insertColumns(self, column, count, parent=QModelIndex())[source]¶
Inserts new columns into the map.
- Parameters
column (int) – column index where to insert
count (int) – number of new columns
parent (QModelIndex) – ignored
- Returns
True if insertion was successful, False otherwise
- Return type
bool
- insertRows(self, row, count, parent=QModelIndex())[source]¶
Inserts new rows into the map.
- Parameters
row (int) – an index where to insert the new data
count (int) – number of rows to insert
parent (QModelIndex) – an index to a parent model
- Returns
True if the operation was successful
- Return type
bool
- _is_in_expanse(self, row, column)[source]¶
Returns True, if given row and column is in the right or bottom ‘expanding’ zone
- Parameters
row (int) – row index
column (int) – column index
- Returns
True if the cell is in the expanse, False otherwise
- Return type
bool
- is_expanse_column(self, column)[source]¶
Returns True if given column is the expanse column.
- Parameters
column (int) – column
- Returns
True if column is expanse column, False otherwise
- Return type
bool
- is_expanse_row(self, row)[source]¶
Returns True if given row is the expanse row.
- Parameters
row (int) – row
- Returns
True if row is the expanse row, False otherwise
- Return type
bool
- removeColumns(self, column, count, parent=QModelIndex())[source]¶
Removes columns from the map.
- Parameters
column (int) – first column to remove
count (int) – number of columns to remove
parent (QModelIndex) – an index to a parent model
- Returns
True if the operation was successful
- removeRows(self, row, count, parent=QModelIndex())[source]¶
Removes rows from the map.
- Parameters
row (int) – first row to remove
count (int) – number of rows to remove
parent (QModelIndex) – an index to a parent model
- Returns
True if the operation was successful
- set_box(self, top_left, bottom_right, data)[source]¶
Sets data for several indexes at once.
- Parameters
top_left (QModelIndex) – a sequence of model indexes
bottom_right (QModelIndex) – a sequence of values corresponding to the indexes
data (list of list) – box of data
- spinetoolbox.mvcmodels.map_model._rows_to_dict(rows)[source]¶
Turns table into nested dictionaries.
- Parameters
rows (list) – a list of row data
- Returns
a nested dictionary
- Return type
dict