spinetoolbox.project_commands

QUndoCommand subclasses for modifying the project.

authors
  1. Marin (KTH)

date

12.2.2020

Module Contents

Classes

SpineToolboxCommand

SetItemSpecificationCommand

Command to set the specification for a Tool.

MoveIconCommand

Command to move icons in the Design view.

SetProjectNameCommand

Command to set the project name.

SetProjectDescriptionCommand

Command to set the project description.

AddProjectItemsCommand

Command to add items.

RemoveAllProjectItemsCommand

Command to remove all items from project.

RemoveProjectItemsCommand

Command to remove items.

RenameProjectItemCommand

Command to rename project items.

AddConnectionCommand

Command to add connection between project items.

RemoveConnectionsCommand

Command to remove links.

SetFiltersOnlineCommand

Command to toggle filter value.

SetConnectionOptionsCommand

Command to set connection options.

AddSpecificationCommand

Command to add item specs to a project.

RemoveSpecificationCommand

Command to remove item specs from a project.

class spinetoolbox.project_commands.SpineToolboxCommand[source]

Bases: PySide2.QtWidgets.QUndoCommand

successfully_undone = False[source]

Flag to register the outcome of undoing a critical command, so toolbox can react afterwards.

static is_critical()[source]

Returns True if this command needs to be undone before closing the project without saving changes.

class spinetoolbox.project_commands.SetItemSpecificationCommand(item, specification)[source]

Bases: SpineToolboxCommand

Command to set the specification for a Tool.

Parameters
  • item (ProjectItem) – the Item

  • specification (ProjectItemSpecification) – the new spec

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.MoveIconCommand(icon, project)[source]

Bases: SpineToolboxCommand

Command to move icons in the Design view.

Parameters
redo(self)[source]
undo(self)[source]
_move_to(self, positions)[source]
class spinetoolbox.project_commands.SetProjectNameCommand(project, name)[source]

Bases: SpineToolboxCommand

Command to set the project name.

Parameters
redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.SetProjectDescriptionCommand(project, description)[source]

Bases: SpineToolboxCommand

Command to set the project description.

Parameters
redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.AddProjectItemsCommand(project, items_dict, set_selected=False, verbosity=True)[source]

Bases: SpineToolboxCommand

Command to add items.

Parameters
  • project (SpineToolboxProject) – the project

  • items_dict (dict) – a mapping from item name to item dict

  • set_selected (bool) – Whether to set item selected after the item has been added to project

  • verbosity (bool) – If True, prints message

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.RemoveAllProjectItemsCommand(project, delete_data=False)[source]

Bases: SpineToolboxCommand

Command to remove all items from project.

Parameters
  • project (SpineToolboxProject) – the project

  • delete_data (bool) – If True, deletes the directories and data associated with the items

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.RemoveProjectItemsCommand(project, item_names, delete_data=False)[source]

Bases: SpineToolboxCommand

Command to remove items.

Parameters
  • project (SpineToolboxProject) – The project

  • item_names (list of str) – Item names

  • delete_data (bool) – If True, deletes the directories and data associated with the item

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.RenameProjectItemCommand(project, previous_name, new_name)[source]

Bases: SpineToolboxCommand

Command to rename project items.

Parameters
  • project (SpineToolboxProject) – the project

  • previous_name (str) – item’s previous name

  • new_name (str) – the new name

redo(self)[source]
undo(self)[source]
static is_critical()[source]

Returns True if this command needs to be undone before closing the project without saving changes.

class spinetoolbox.project_commands.AddConnectionCommand(project, source_name, source_position, destination_name, destination_position)[source]

Bases: SpineToolboxCommand

Command to add connection between project items.

Parameters
  • project (SpineToolboxProject) – project

  • source_name (str) – source item’s name

  • source_position (str) – link’s position on source item’s icon

  • destination_name (str) – destination item’s name

  • destination_position (str) – link’s position on destination item’s icon

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.RemoveConnectionsCommand(project, connections)[source]

Bases: SpineToolboxCommand

Command to remove links.

Parameters
  • project (SpineToolboxProject) – project

  • connections (list of Connection) – the connections

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.SetFiltersOnlineCommand(resource_filter_model, resource, filter_type, online)[source]

Bases: SpineToolboxCommand

Command to toggle filter value.

Parameters
  • resource_filter_model (ResourceFilterModel) – filter model

  • resource (str) – resource label

  • filter_type (str) – filter type identifier

  • online (dict) – mapping from scenario/tool id to online flag

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.SetConnectionOptionsCommand(link, options)[source]

Bases: SpineToolboxCommand

Command to set connection options.

Parameters
  • link (Link) –

  • options (dict) – containing options to be set

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.AddSpecificationCommand(toolbox, specification)[source]

Bases: SpineToolboxCommand

Command to add item specs to a project.

Parameters
  • toolbox (ToolboxUI) – the toolbox

  • specification (ProjectItemSpecification) – the spec

redo(self)[source]
undo(self)[source]
class spinetoolbox.project_commands.RemoveSpecificationCommand(toolbox, row, ask_verification)[source]

Bases: SpineToolboxCommand

Command to remove item specs from a project.

Parameters
  • toolbox (ToolboxUI) – the toolbox

  • row (int) – the row in the ProjectItemSpecPaletteModel

  • ask_verification (bool) – if True, shows confirmation message the first time

redo(self)[source]
undo(self)[source]