spinetoolbox.spine_db_commands

QUndoCommand subclasses for modifying the db.

authors
  1. Marin (KTH)

date

31.1.2020

Module Contents

Classes

AgedUndoStack

AgedUndoCommand

param parent

The parent command, used for defining macros.

SpineDBCommand

param db_mngr

SpineDBManager instance

AddItemsCommand

param db_mngr

SpineDBManager instance

CheckAddParameterValuesCommand

param db_mngr

SpineDBManager instance

UpdateItemsCommand

param db_mngr

SpineDBManager instance

CheckUpdateParameterValuesCommand

param db_mngr

SpineDBManager instance

RemoveItemsCommand

param db_mngr

SpineDBManager instance

Functions

_cache_to_db_relationship_class(item)

_cache_to_db_relationship(item)

_cache_to_db_parameter_definition(item)

_cache_to_db_parameter_value(item)

_cache_to_db_parameter_value_list(item)

_cache_to_db_entity_group(item)

_cache_to_db_item(item_type, item)

_format_item(item_type, item)

spinetoolbox.spine_db_commands._cache_to_db_relationship_class(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_relationship(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_parameter_definition(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_parameter_value(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_parameter_value_list(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_entity_group(item)[source]
spinetoolbox.spine_db_commands._cache_to_db_item(item_type, item)[source]
spinetoolbox.spine_db_commands._format_item(item_type, item)[source]
class spinetoolbox.spine_db_commands.AgedUndoStack[source]

Bases: PySide2.QtWidgets.QUndoStack

property redo_age(self)[source]
property undo_age(self)[source]
commands(self)[source]
class spinetoolbox.spine_db_commands.AgedUndoCommand(parent=None)[source]

Bases: PySide2.QtWidgets.QUndoCommand

Parameters

parent (QUndoCommand, optional) – The parent command, used for defining macros.

redo(self)[source]
undo(self)[source]
property age(self)[source]
class spinetoolbox.spine_db_commands.SpineDBCommand(db_mngr, db_map, parent=None)[source]

Bases: AgedUndoCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

_add_command_name[source]
_update_command_name[source]
_add_method_name[source]
_readd_method_name[source]
_update_method_name[source]
_get_method_name[source]
_added_signal_name[source]
_updated_signal_name[source]
static redomethod(func)[source]

Returns a new redo method that determines if the command was completed. The command is completed if calling the function triggers the completed_signal. Once the command is completed, we don’t listen to the signal anymore and we also silence the affected Spine db editors. If the signal is not received, then the command is declared obsolete.

static undomethod(func)[source]

Returns a new undo method that silences the affected Spine db editors.

receive_items_changed(self, _db_map_data)[source]

Marks the command as completed.

abstract data(self)[source]

Returns data to present this command in a DBHistoryDialog.

class spinetoolbox.spine_db_commands.AddItemsCommand(db_mngr, db_map, data, item_type, parent=None)[source]

Bases: SpineDBCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • data (list) – list of dict-items to add

  • item_type (str) – the item type

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

redo(self)[source]
undo(self)[source]
receive_items_changed(self, db_map_data)[source]

Marks the command as completed.

data(self)[source]

Returns data to present this command in a DBHistoryDialog.

class spinetoolbox.spine_db_commands.CheckAddParameterValuesCommand(db_mngr, db_map, data, parent=None)[source]

Bases: AddItemsCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • data (list) – list of dict-items to add

  • item_type (str) – the item type

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

class spinetoolbox.spine_db_commands.UpdateItemsCommand(db_mngr, db_map, data, item_type, parent=None)[source]

Bases: SpineDBCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • data (list) – list of dict-items to update

  • item_type (str) – the item type

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

_undo_item(self, db_map, redo_item)[source]
redo(self)[source]
undo(self)[source]
data(self)[source]

Returns data to present this command in a DBHistoryDialog.

class spinetoolbox.spine_db_commands.CheckUpdateParameterValuesCommand(db_mngr, db_map, data, parent=None)[source]

Bases: UpdateItemsCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • data (list) – list of dict-items to update

  • item_type (str) – the item type

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

class spinetoolbox.spine_db_commands.RemoveItemsCommand(db_mngr, db_map, typed_data, parent=None)[source]

Bases: SpineDBCommand

Parameters
  • db_mngr (SpineDBManager) – SpineDBManager instance

  • db_map (DiffDatabaseMapping) – DiffDatabaseMapping instance

  • typed_data (dict) – lists of dict-items to remove keyed by string type

  • parent (QUndoCommand, optional) – The parent command, used for defining macros.

redo(self)[source]
undo(self)[source]
receive_items_changed(self, typed_db_map_data)[source]

Marks the command as completed.

data(self)[source]

Returns data to present this command in a DBHistoryDialog.