spinetoolbox.mvcmodels.pivot_table_models

Provides pivot table models for the Tabular View.

author:
  1. Vennström (VTT)
date:

1.11.2018

Module Contents

class spinetoolbox.mvcmodels.pivot_table_models.PivotTableModel(parent)[source]

Bases: PySide2.QtCore.QAbstractTableModel

Parameters:parent (TabularViewForm) –
_V_HEADER_WIDTH = 5[source]
_ITEMS_TO_FETCH = 1024[source]
plot_x_column[source]

Returns the index of the column designated as Y values for plotting or None.

reset_data_count(self)[source]
canFetchMore(self, parent)[source]
fetchMore(self, parent)[source]
fetch_more_rows(self, parent)[source]
fetch_more_columns(self, parent)[source]
reset_model(self, data, index_ids, rows=(), columns=(), frozen=(), frozen_value=())[source]
clear_model(self)[source]
update_model(self, data)[source]
add_to_model(self, data)[source]
remove_from_model(self, data)[source]
set_pivot(self, rows, columns, frozen, frozen_value)[source]
set_frozen_value(self, frozen_value)[source]
set_plot_x_column(self, column, is_x)[source]

Sets or clears the Y flag on a column

first_data_row(self)[source]

Returns the row index to the first data row.

headerRowCount(self)[source]

Returns number of rows occupied by header.

headerColumnCount(self)[source]

Returns number of columns occupied by header.

dataRowCount(self)[source]

Returns number of rows that contain actual data.

dataColumnCount(self)[source]

Returns number of columns that contain actual data.

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

Number of rows in table, number of header rows + datarows + 1 empty row

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

Number of columns in table, number of header columns + datacolumns + 1 empty columns

flags(self, index)[source]

Roles for data

top_left_indexes(self)[source]

Returns indexes in the top left area.

Returns
list(QModelIndex): top indexes (horizontal headers, associated to rows) list(QModelIndex): left indexes (vertical headers, associated to columns)
index_in_top(self, index)[source]
index_in_left(self, index)[source]
index_in_top_left(self, index)[source]

Returns whether or not the given index is in top left corner, where pivot names are displayed

index_in_column_headers(self, index)[source]

Returns whether or not the given index is in column headers (horizontal) area

index_in_row_headers(self, index)[source]

Returns whether or not the given index is in row headers (vertical) area

index_in_headers(self, index)[source]
index_in_empty_column_headers(self, index)[source]

Returns whether or not the given index is in empty column headers (vertical) area

index_in_empty_row_headers(self, index)[source]

Returns whether or not the given index is in empty row headers (vertical) area

index_in_data(self, index)[source]

Returns whether or not the given index is in data area

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

Returns a tuple of row and column in the pivot model that corresponds to the given model index.

Parameters:index (QModelIndex) –
Returns:row int: column
Return type:int
_top_left_id(self, index)[source]

Returns the id of the top left header corresponding to the given header index.

Parameters:index (QModelIndex) –
Returns:int, NoneType
_header_id(self, index)[source]

Returns the id of the given row or column header index.

Parameters:index (QModelIndex) –
Returns:int, NoneType
_header_ids(self, row, column)[source]

Returns the ids for the headers at given row and column.

Parameters:
  • row (int) –
  • column (int) –
Returns:

tuple(int)

_header_name(self, top_left_id, header_id)[source]

Returns the name of the header given by top_left_id and header_id.

Parameters:
  • top_left_id (int) – The id of the top left header
  • header_id (int) – The header id
Returns
str
header_name(self, index)[source]

Returns the name corresponding to the given header index.

Parameters:index (QModelIndex) –
Returns:str
header_data(self, index, role=Qt.DisplayRole)[source]

Returns the data corresponding to the given header index based on role enum.

Parameters:
  • index (QModelIndex) –
  • role (enum Qt.ItemDataRole) –
Returns:

str

header_names(self, index)[source]

Returns the header names corresponding to the given data index.

Parameters:index (QModelIndex) –
Returns:object names str: parameter name
Return type:list(str)
value_name(self, index)[source]

Returns a string that concatenates the header names corresponding to the given data index.

Parameters:index (QModelIndex) –
Returns:str
column_name(self, column)[source]

Returns a string that concatenates the header names corresponding to the given column.

Parameters:column (int) –
Returns:str
_color_data(self, index)[source]
data(self, index, role=Qt.DisplayRole)[source]
setData(self, index, value, role=Qt.EditRole)[source]
batch_set_data(self, indexes, values)[source]
_batch_set_inner_data(self, inner_data)[source]
_batch_set_parameter_value_data(self, row_map, column_map, data, values)[source]
_checked_parameter_values(self, items)[source]
_add_parameter_values(self, items)[source]
_update_parameter_values(self, items)[source]
_batch_set_relationship_data(self, row_map, column_map, data, values)[source]
_batch_set_header_data(self, header_data)[source]
_batch_set_empty_header_data(self, header_data, get_top_left_id)[source]
class spinetoolbox.mvcmodels.pivot_table_models.PivotTableSortFilterProxy(parent=None)[source]

Bases: PySide2.QtCore.QSortFilterProxyModel

Initialize class.

set_filter(self, identifier, filter_value)[source]

Sets filter for a given index (object class) name.

Parameters:
  • identifier (int) – index identifier
  • filter_value (set, None) – A set of accepted values, or None if no filter (all pass)
clear_filter(self)[source]
accept_index(self, index, index_ids)[source]
filterAcceptsRow(self, source_row, source_parent)[source]

Returns true if the item in the row indicated by the given source_row and source_parent should be included in the model; otherwise returns false.

filterAcceptsColumn(self, source_column, source_parent)[source]

Returns true if the item in the column indicated by the given source_column and source_parent should be included in the model; otherwise returns false.

batch_set_data(self, indexes, values)[source]