spinetoolbox.import_editor.commands

Contains undo and redo commands for Import editor.

author:
  1. Soininen (VTT)
date:

4.8.2020

Module Contents

Classes

_Id Enum where members are also (and must be) ints
PasteMappings Command to paste copied mappings
PasteOptions Command to paste copied mapping options.
SetTableChecked Command to change a source table’s checked state.
RenameMapping A command to change the name of a mapping.
SetComponentMappingType Sets the type of a component mapping.
SetComponentMappingReference Sets the reference for a component mapping.
SetConnectorOption Command to set a ConnectorManager option.
CreateMapping Creates a new mapping.
DeleteMapping Command to delete a mapping.
SetItemMappingType Command to change item mapping’s type.
SetImportObjectsFlag Command to set item mapping’s import objects flag.
SetParameterType Command to change the parameter type of an item mapping.
SetReadStartRow Command to change item mapping’s read start row option.
SetItemMappingDimension Command to change item mapping’s dimension option.
SetTimeSeriesRepeatFlag Command to change the repeat flag for time series.
SetMapDimensions Command to change the dimensions of a Map parameter value type.
SetMapCompressFlag Command to change the Map compress flag.
SetColumnOrRowType Command to change the type of columns or rows.
RestoreMappingsFromDict Restores mappings from a dict.
class spinetoolbox.import_editor.commands._Id[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

Initialize self. See help(type(self)) for accurate signature.

SET_OPTION[source]
class spinetoolbox.import_editor.commands.PasteMappings(import_editor, source_table_name, copied_mappings, previous_mappings)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to paste copied mappings

Parameters:
  • import_editor (ImportEditor) – import editor
  • source_table_name (src) – name of the target source table
  • copied_mappings (Iterable) – mappings to paste
  • previous_mappings (Iterable) – mappings before pasting
redo(self)[source]

Pastes the copied mappings

undo(self)[source]

Restores mappings to their previous state.

class spinetoolbox.import_editor.commands.PasteOptions(import_editor, source_table_name, copied_options, previous_options)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to paste copied mapping options.

Parameters:
  • import_editor (ImportEditor) – import editor
  • source_table_name (src) – name of the target source table
  • copied_options (dict) – options from the internal clipboard
  • previous_options (dict) – previous options
redo(self)[source]

Pastes the options.

undo(self)[source]

Restores the options to their previous values.

class spinetoolbox.import_editor.commands.SetTableChecked(table_name, table_list_model, row, checked)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change a source table’s checked state.

Parameters:
  • table_name (str) – source table name
  • table_list_model (SourceTableListModel) – source table model
  • row (int) – table row on the list
  • checked (bool) – new checked state
redo(self)[source]

Changes the checked state.

undo(self)[source]

Restores the previous checked state.

class spinetoolbox.import_editor.commands.RenameMapping(row, mapping_list_model, name, previous_name)[source]

Bases: PySide2.QtWidgets.QUndoCommand

A command to change the name of a mapping.

Parameters:
  • mapping_list_model (MappingListModel) – model holding the mapping names
  • name (str) – new name
  • previous_name (str) – original name
redo(self)[source]

Renames the mapping.

undo(self)[source]

Reverts renaming of the mapping.

class spinetoolbox.import_editor.commands.SetComponentMappingType(component_display_name, mapping_specification_model, mapping_type, previous_type, previous_reference)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Sets the type of a component mapping.

Parameters:
  • component_display_name (str) – component name on the mapping specification table
  • mapping_specification_model (MappingSpecificationModel) – specification model
  • mapping_type (str) – name of the new type
  • previous_type (str) – name of the original type
  • previous_reference (str or int) – original mapping’s reference
redo(self)[source]

Changes a component mapping’s type.

undo(self)[source]

Restores component mapping’s original type.

class spinetoolbox.import_editor.commands.SetComponentMappingReference(component_display_name, mapping_specification_model, reference, previous_reference, previous_mapping_type_was_none)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Sets the reference for a component mapping.

Parameters:
  • component_display_name (str) – component name on the mapping specification table
  • mapping_specification_model (MappingSpecificationModel) – specification model
  • reference (str or int) – new value for the reference
  • previous_reference (str or int) – preference’s original value
  • previous_mapping_type_was_none (bool) – True if the mapping was originally a NoneMapping
redo(self)[source]

Sets the reference’s value.

undo(self)[source]

Restores the reference’s value and, if necessary, mapping type to their original values.

class spinetoolbox.import_editor.commands.SetConnectorOption(source_table, option_key, options_widget, value, previous_value)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to set a ConnectorManager option.

Parameters:
  • source_table (str) – source table name
  • option_key (str) – option’s key
  • options_widget (OptionsWidget) – connector options widget
  • value (str or int or bool) – option’s new value
  • previous_value (str or int or bool) – option’s previous value
id(self)[source]

This command’s id.

Returns:id
Return type:int
mergeWith(self, command)[source]

Merges command with another SetConnectorOption.

Parameters:command (QUndoCommand) – a command to merge with
Returns:True if merge was successful, False otherwise
Return type:bool
redo(self)[source]

Changes the connector’s option.

undo(self)[source]

Restores the option back to its original value.

class spinetoolbox.import_editor.commands.CreateMapping(source_table_name, import_mappings, row)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Creates a new mapping.

Parameters:
  • source_table_name (src) – source table name
  • import_mappings (ImportMappings) – mappings manager
  • row (int) – row where the new mapping should be created
redo(self)[source]

Creates a new mapping at the given row in mappings list.

undo(self)[source]

Deletes the created mapping.

class spinetoolbox.import_editor.commands.DeleteMapping(source_table_name, import_mappings, mapping_name, row)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to delete a mapping.

Parameters:
  • source_table_name (src) – source table name
  • import_mappings (ImportMappings) – mappings manager
  • mapping_name (str) – name of the mapping to delete
  • row (int) – mapping’s row in the mapping list
redo(self)[source]

Deletes the mapping.

undo(self)[source]

Restores the deleted mapping.

class spinetoolbox.import_editor.commands.SetItemMappingType(source_table_name, mapping_specification_name, options_widget, new_type, previous_mapping)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change item mapping’s type.

Parameters:
  • source_table_name (src) – name of the source table
  • mapping_specification_name (str) – name of the mapping
  • options_widget (ImportMappingOptions) – options widget
  • new_type (str) – name of the new mapping type
  • previous_mapping (ItemMappingBase) – the previous mapping
redo(self)[source]

Sets the mapping type to its new value.

undo(self)[source]

Resets the mapping type to its former value.

class spinetoolbox.import_editor.commands.SetImportObjectsFlag(source_table_name, mapping_specification_name, options_widget, import_objects)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to set item mapping’s import objects flag.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • import_objects (bool) – new flag value
redo(self)[source]

Changes the import objects flag.

undo(self)[source]

Restores the import objects flag.

class spinetoolbox.import_editor.commands.SetParameterType(source_table_name, mapping_specification_name, options_widget, new_type, previous_parameter)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change the parameter type of an item mapping.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • new_type (str) – name of the new parameter type
  • previous_parameter (ParameterDefinitionMapping) – previous parameter mapping
redo(self)[source]

Changes a parameter’s type.

undo(self)[source]

Restores a parameter to its previous type

class spinetoolbox.import_editor.commands.SetReadStartRow(source_table_name, mapping_specification_name, options_widget, start_row, previous_start_row)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change item mapping’s read start row option.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • start_row (int) – new read start row
  • previous_start_row (int) – previous read start row value
redo(self)[source]

Changes item mapping’s read start row to a new value.

undo(self)[source]

Restores item mapping’s read start row to its previous value.

class spinetoolbox.import_editor.commands.SetItemMappingDimension(source_table_name, mapping_specification_name, options_widget, dimension, previous_dimension)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change item mapping’s dimension option.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • dimension (int) – new dimension
  • previous_dimension (int) – previous dimension
redo(self)[source]

Changes the item mapping’s dimension to the new value.

undo(self)[source]

Changes the item mapping’s dimension to its previous value.

class spinetoolbox.import_editor.commands.SetTimeSeriesRepeatFlag(source_table_name, mapping_specification_name, options_widget, repeat)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change the repeat flag for time series.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • repeat (bool) – new repeat flag value
redo(self)[source]

Sets the repeat flag to given value.

undo(self)[source]

Restores the repeat flag to its previous value.

class spinetoolbox.import_editor.commands.SetMapDimensions(source_table_name, mapping_specification_name, options_widget, dimensions, previous_dimensions)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change the dimensions of a Map parameter value type.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • dimensions (int) – new dimensions
  • previous_dimensions (int) – previous dimensions
redo(self)[source]

Sets the Map dimensions to the new value.

undo(self)[source]

Restores the previous Map dimensions value.

class spinetoolbox.import_editor.commands.SetMapCompressFlag(source_table_name, mapping_specification_name, options_widget, compress)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change the Map compress flag.

Parameters:
  • source_table_name (str) – name of the source table
  • mapping_specification_name (str) – name of the mapping specification
  • options_widget (ImportMappingOptions) – options widget
  • compress (bool) – compress flag value
redo(self)[source]

Sets the compress flag.

undo(self)[source]

Resets the compress flag to previous value.

class spinetoolbox.import_editor.commands.SetColumnOrRowType(source_table_name, header_widget, sections, new_type, previous_type)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Command to change the type of columns or rows.

Parameters:
  • source_table_name (src) – name of the source table
  • header_widget (HeaderWithButton) – widget of origin
  • sections (Iterable of int) – row or column indexes
  • new_type (ConvertSpec) – conversion specification for the rows/columns
  • previous_type (ConvertSpec) – previous conversion specification for the rows/columns
redo(self)[source]

Sets column/row type.

undo(self)[source]

Restores column/row type to its previous value.

class spinetoolbox.import_editor.commands.RestoreMappingsFromDict(import_editor, mapping_dict)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Restores mappings from a dict.

Parameters:
  • import_editor (ImportEditor) – import editor
  • mapping_dict (dict) – mappings to
redo(self)[source]

Restores the mappings.

undo(self)[source]

Reverts back to previous mappings.