spinetoolbox.project_items.exporter.widgets.parameter_index_settings

Parameter indexing settings window for .gdx export.

author:
  1. Soininen (VTT)
date:

26.11.2019

Module Contents

class spinetoolbox.project_items.exporter.widgets.parameter_index_settings.IndexSettingsState[source]

Bases: enum.Enum

An enumeration indicating the state of the settings window.

OK[source]
DOMAIN_MISSING_INDEXES[source]
DOMAIN_NAME_MISSING[source]
DOMAIN_NAME_CLASH[source]
class spinetoolbox.project_items.exporter.widgets.parameter_index_settings.ParameterIndexSettings(parameter_name, indexing_setting, available_existing_domains, new_domains, parent)[source]

Bases: PySide2.QtWidgets.QWidget

A widget showing setting for a parameter with indexed values.

Parameters:
  • parameter_name (str) – parameter’s name
  • indexing_setting (IndexingSetting) – indexing settings for the parameter
  • available_existing_domains (dict) – a dict from existing domain name to a list of its record keys
  • new_domains (dict) – a dict from new domain name to a list of its record keys
  • parent (QWidget) – a parent widget
new_domain_name[source]

name of the new domain

state[source]

widget’s state

is_using_domain(self, domain_name)[source]
indexing_domain(self)[source]

Provides information needed to expand the parameter’s indexed values.

Returns:a tuple of IndexingDomain and a Set if a new domain is needed for indexing, otherwise None
Return type:tuple
notification_message(self, message)[source]

Shows a notification message on the widget.

warning_message(self, message)[source]

Shows a warning message on the widget.

error_message(self, message)[source]

Shows an error message on the widget.

reorder_indexes(self, first, last, target)[source]
_check_state(self)[source]

Updated the widget’s state.

_check_errors(self, mapped_values_balance)[source]

Checks if the parameter is correctly indexed.

_check_warnings(self, mapped_values_balance)[source]

Checks if there are non-fatal issues with parameter indexing.

_update_indexing_domains_name(self, domain_name=None)[source]

Updates the model’s header and the label showing the indexing domains.

Parameters:domain_name (str) – indexing domain’s name or None to read it from the other widgets.
_domain_name_changed(self, text)[source]

Reacts to changes in indexing domain name.

_set_enabled_use_existing_domain_widgets(self, enabled)[source]

Enables and disables controls used to set up indexing based on an existing domain.

_set_enabled_create_domain_widgets(self, enabled)[source]

Enables and disables controls used to set up indexing based on a new domain.

_existing_domain_changed(self, index)[source]

Reacts to changes in existing domains combo box.

_update_index_list_selection(self, expression, clear_selection_if_expression_empty=True)[source]

Updates selection according to changed selection expression.

_update_model_to_selection(self, selected, deselected)[source]

Updates the model after table selection has changed.

_generate_index(self, expression)[source]

Builds indexes according to given expression.

_extract_index_from_parameter(self, _=True)[source]

Assigns indexes from the parameter to the model.

_move_indexing_domain_left(self, _)[source]

Moves the indexing domain name left on the indexing label.

_move_indexing_domain_right(self, _)[source]

Moves the indexing domain name right on the indexing label.

class spinetoolbox.project_items.exporter.widgets.parameter_index_settings._IndexingTableModel(parameter)[source]

Bases: PySide2.QtCore.QAbstractTableModel

A table model for parameter value indexing.

First column contains the proposed new index keys. The rest of the columns contain the parameter values for each set of existing index keys. Only selected new index keys are used for indexing. Unselected rows are left empty.

Parameters:parameter (Parameter) – a parameter to model
indexes[source]

a string list of all new indexing keys

index_selection[source]

a boolean list of selected index keys, so called pick list

clear(self)[source]

Clears the model.

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

Returns the number of columns.

data(self, index, role=Qt.DisplayRole)[source]

Returns data associated with given model index and role.

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

Returns header data.

mapped_values_balance(self)[source]

Returns the balance between available indexes and parameter values.

Zero means that there is as many indexes available as there are values, i.e. the parameter is ‘perfectly’ indexed. A positive value means there are more indexes than values while a negative value means there are not enough indexes for all values.

Returns:mapped values’ balance
Return type:int
reorder_indexes(self, first, last, target)[source]

Moves indexes around.

Parameters:
  • first (int) – first index to move
  • last (int) – last index to move (inclusive)
  • target (int) – where to move the first index
rowCount(self, parent=QModelIndex())[source]

Return the number of rows.

selection_changed(self, selected, deselected)[source]

Updates selected and deselected rows on the table.

set_index_name(self, name)[source]

Sets the indexing domain name.

set_indexes(self, indexes)[source]

Overwrites all new indexes.