spinetoolbox.project_tree_item

Project Tree items.

authors
  1. Soininen (VTT)

date

17.1.2020

Module Contents

Classes

BaseProjectTreeItem

Base class for all project tree items.

RootProjectTreeItem

Class for the root project tree item.

CategoryProjectTreeItem

Class for category project tree items.

LeafProjectTreeItem

Class for leaf items in the project item tree.

class spinetoolbox.project_tree_item.BaseProjectTreeItem(name, description)[source]

Bases: spinetoolbox.metaobject.MetaObject

Base class for all project tree items.

Parameters
  • name (str) – Object name

  • description (str) – Object description

flags(self)[source]

Returns the item flags.

parent(self)[source]

Returns parent project tree item.

child_count(self)[source]

Returns the number of child project tree items.

children(self)[source]

Returns the children of this project tree item.

child(self, row)[source]

Returns child BaseProjectTreeItem on given row.

Parameters

row (int) – Row of child to return

Returns

item on given row or None if it does not exist

Return type

BaseProjectTreeItem

row(self)[source]

Returns the row on which this item is located.

abstract add_child(self, child_item)[source]

Base method that shall be overridden in subclasses.

remove_child(self, row)[source]

Remove the child of this BaseProjectTreeItem from given row. Do not call this method directly. This method is called by ProjectItemTreeModel when items are removed.

Parameters

row (int) – Row of child to remove

Returns

True if operation succeeded, False otherwise

Return type

bool

abstract custom_context_menu(self, toolbox)[source]

Returns the context menu for this item. Implement in subclasses as needed.

Parameters

toolbox (QWidget) – The widget that is controlling the menu

Returns

context menu

Return type

QMenu

class spinetoolbox.project_tree_item.RootProjectTreeItem[source]

Bases: BaseProjectTreeItem

Class for the root project tree item.

Parameters
  • name (str) – Object name

  • description (str) – Object description

add_child(self, child_item)[source]

Adds given category item as the child of this root project tree item. New item is added as the last item.

Parameters

child_item (CategoryProjectTreeItem) – Item to add

Returns

True for success, False otherwise

abstract custom_context_menu(self, toolbox)[source]

See base class.

class spinetoolbox.project_tree_item.CategoryProjectTreeItem(name, description)[source]

Bases: BaseProjectTreeItem

Class for category project tree items.

Parameters
  • name (str) – Object name

  • description (str) – Object description

flags(self)[source]

Returns the item flags.

add_child(self, child_item)[source]

Adds given project tree item as the child of this category item. New item is added as the last item.

Parameters

child_item (LeafProjectTreeTreeItem) – Item to add

Returns

True for success, False otherwise

custom_context_menu(self, toolbox)[source]

Returns the context menu for this item.

Parameters

toolbox (ToolboxUI) – Toolbox main window

Returns

context menu

Return type

QMenu

class spinetoolbox.project_tree_item.LeafProjectTreeItem(project_item, toolbox)[source]

Bases: BaseProjectTreeItem

Class for leaf items in the project item tree.

Parameters
  • project_item (ProjectItem) – the real project item this item represents

  • toolbox (ToolboxUI) – a toolbox instance

property project_item(self)[source]

the project item linked to this leaf

property toolbox(self)[source]

the toolbox instance

abstract add_child(self, child_item)[source]

See base class.

flags(self)[source]

Returns the item flags.

custom_context_menu(self, toolbox)[source]

Returns the context menu for this item.

Parameters

toolbox (ToolboxUI) – Toolbox main window

Returns

context menu

Return type

QMenu