spinetoolbox.project_items.exporter.widgets.gdx_export_settings

Export item’s settings window for .gdx export.

author:
  1. Soininen (VTT)
date:

9.9.2019

Module Contents

class spinetoolbox.project_items.exporter.widgets.gdx_export_settings.State[source]

Bases: enum.Enum

Gdx Export Settings window state

OK[source]

Settings are ok.

BAD_INDEXING[source]

Not all indexed parameters are set up correctly.

class spinetoolbox.project_items.exporter.widgets.gdx_export_settings.GdxExportSettings(settings, indexing_settings, new_indexing_domains, merging_settings, new_merging_domains, database_path, parent)[source]

Bases: PySide2.QtWidgets.QWidget

A setting window for exporting .gdx files.

Parameters:
  • settings (Settings) – export settings
  • indexing_settings (dict) – indexing domain information for indexed parameter values
  • new_indexing_domains (list) – list of additional domains needed for indexed parameter
  • merging_settings (dict) – parameter merging settings
  • new_merging_domains (list) – list of additional domains needed for parameter merging
  • database_path (str) – database URL
  • parent (QWidget) – a parent widget
reset_requested[source]

Emitted when Reset Defaults button has been clicked.

settings_accepted[source]

Emitted when the OK button has been clicked.

settings_rejected[source]

Emitted when the Cancel button has been clicked.

settings[source]

the settings object

indexing_settings[source]

indexing settings dict

indexing_domains[source]

list of additional domains needed for indexing

merging_settings[source]

dictionary of merging settings

merging_domains[source]

list of additional domains needed for parameter merging

reset_settings(self, settings, indexing_settings, new_indexing_domains, merging_settings, new_merging_domains)[source]

Resets all settings.

_check_state(self)[source]

Checks if there are parameters in need for indexing.

_populate_global_parameters_combo_box(self, settings)[source]

(Re)populates the global parameters combo box.

_update_new_domains_list(self, domains, old_list)[source]

Merges entries from new and old domain lists.

handle_settings_state_changed(self, state)[source]
_accept(self)[source]

Emits the settings_accepted signal.

_move_sets_up(self, checked=False)[source]

Moves selected domains and sets up one position.

_move_sets_down(self, checked=False)[source]

Moves selected domains and sets down one position.

_move_records_up(self, checked=False)[source]

Moves selected records up and position.

_move_records_down(self, checked=False)[source]

Moves selected records down on position.

_reject(self)[source]

Hides the window.

closeEvent(self, event)[source]
_reset_settings(self, button)[source]

Requests for fresh settings to be read from the database.

_update_global_parameters_domain(self, text)[source]

Updates the global parameters domain name.

_populate_set_contents(self, selected, _)[source]

Populates the record list by the selected domain’s or set’s records.

_sort_records_alphabetically(self, _)[source]

Sorts the lists of set records alphabetically.

_show_indexed_parameter_settings(self, _)[source]

Shows the indexed parameter settings window.

_show_parameter_merging_settings(self, _)[source]

Shows the parameter merging settings window.

_approve_parameter_indexing_settings(self)[source]

Gathers settings from the indexed parameters settings window.

_parameter_merging_approved(self)[source]

Collects merging settings from the parameter merging window.

_dispose_parameter_indexing_settings_window(self)[source]

Removes references to the indexed parameter settings window.

_dispose_parameter_merging_window(self)[source]

Removes references to the parameter merging settings window.

class spinetoolbox.project_items.exporter.widgets.gdx_export_settings.GAMSSetListModel(settings)[source]

Bases: PySide2.QtCore.QAbstractListModel

A model to configure the domain and set name lists in gdx export settings.

This model combines the domain and set name lists into a single list. The two ‘parts’ are differentiated by different background colors. Items from each part cannot be mixed with the other. Both the ordering of the items within each list as well as their exportability flags are handled here.

Parameters:settings (spine_io.exporters.gdx.Settings) – settings whose domain and set name lists should be modelled
add_domain(self, domain)[source]

Adds a new domain.

drop_domain(self, domain)[source]

Removes a domain.

update_domain(self, domain)[source]

Updates an existing domain.

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

Returns the value for given role at given index.

Qt.DisplayRole returns the name of the domain or set while Qt.CheckStateRole returns whether the exportable flag has been set or not. Qt.BackgroundRole gives the item’s background depending whether it is a domain or a set.

Parameters:
  • index (QModelIndex) – an index to the model
  • role (int) – the query’s role
Returns:

the requested value or None

flags(self, index)[source]

Returns an item’s flags.

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

Returns an empty string for horizontal header and row number for vertical header.

index_for_domain(self, domain_name)[source]

Returns the model index for a domain.

is_domain(self, index)[source]

Returns True if index points to a domain name, otherwise returns False.

moveRows(self, sourceParent, sourceRow, count, destinationParent, destinationChild)[source]

Moves the domain and set names around.

The names cannot be mixed between domains and sets.

Parameters:
  • sourceParent (QModelIndex) – parent from which the rows are moved
  • sourceRow (int) – index of the first row to be moved
  • count (int) – number of rows to move
  • destinationParent (QModelIndex) – parent to which the rows are moved
  • destinationChild (int) – index where to insert the moved rows
Returns:

True if the operation was successful, False otherwise

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

Returns the number of rows.

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

Sets the exportable flag status for given row.

class spinetoolbox.project_items.exporter.widgets.gdx_export_settings.GAMSRecordListModel[source]

Bases: PySide2.QtCore.QAbstractListModel

A model to manage record ordering within domains and sets.

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

With role == Qt.DisplayRole returns the record’s keys as comma separated string.

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

Returns row and column header data.

moveRows(self, sourceParent, sourceRow, count, destinationParent, destinationChild)[source]

Moves the records around.

Parameters:
  • sourceParent (QModelIndex) – parent from which the rows are moved
  • sourceRow (int) – index of the first row to be moved
  • count (int) – number of rows to move
  • destinationParent (QModelIndex) – parent to which the rows are moved
  • destinationChild (int) – index where to insert the moved rows
Returns:

True if the operation was successful, False otherwise

reset(self, records, set_name)[source]

Resets the model’s record data.

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

Return the number of records in the model.

sort_alphabetically(self)[source]