spinetoolbox.project_tree_item

Project Tree items.

authors:
  1. Soininen (VTT)
date:

17.1.2020

Module Contents

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.

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 LeafProjectItemTreeModel when items are removed.

Parameters:row (int) – Row of child to remove
Returns:True if operation succeeded, False otherwise
Return type:bool
custom_context_menu(self, parent, pos)[source]

Returns the context menu for this item. Implement in subclasses as needed. :param parent: The widget that is controlling the menu :type parent: QWidget :param pos: Position on screen :type pos: QPoint

apply_context_menu_action(self, parent, action)[source]

Applies given action from context menu. Implement in subclasses as needed.

Parameters:
  • parent (QWidget) – The widget that is controlling the menu
  • action (str) – The selected action
class spinetoolbox.project_tree_item.RootProjectTreeItem[source]

Bases: spinetoolbox.project_tree_item.BaseProjectTreeItem

Class for the root project tree item.

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
custom_context_menu(self, parent, pos)[source]

See base class.

apply_context_menu_action(self, parent, action)[source]

See base class.

class spinetoolbox.project_tree_item.CategoryProjectTreeItem(name, description, item_maker, icon_maker, add_form_maker, properties_ui)[source]

Bases: spinetoolbox.project_tree_item.BaseProjectTreeItem

Class for category project tree items.

Parameters:
  • name (str) – Category name
  • description (str) – Category description
  • item_maker (function) – A function for creating project items in this category
  • icon_maker (function) – A function for creating icons (QGraphicsItems) for project items in this category
  • add_form_maker (function) – A function for creating the form to add project items to this category
  • properties_ui (object) – An object holding the Item Properties UI
flags(self)[source]

Returns the item flags.

item_maker(self)[source]

Returns the item maker method.

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
  • toolbox (ToolboxUI) – A toolbox instance
Returns:

True for success, False otherwise

custom_context_menu(self, parent, pos)[source]

Returns the context menu for this item.

Parameters:
  • parent (QWidget) – The widget that is controlling the menu
  • pos (QPoint) – Position on screen
apply_context_menu_action(self, parent, action)[source]

Applies given action from context menu.

Parameters:
  • parent (QWidget) – The widget that is controlling the menu
  • action (str) – The selected action
class spinetoolbox.project_tree_item.LeafProjectTreeItem(project_item, toolbox)[source]

Bases: spinetoolbox.project_tree_item.BaseProjectTreeItem

Class for leaf items in the project item tree.

Parameters:
  • project_item (ProjectItem) – the real project item this item represents
  • toolbox (ToobloxUI) – a toolbox instance
project_item[source]

the project item linked to this leaf

toolbox[source]

the toolbox instance

add_child(self, child_item)[source]

See base class.

flags(self)[source]

Returns the item flags.

custom_context_menu(self, parent, pos)[source]

Returns the context menu for this item.

Parameters:
  • parent (QWidget) – The widget that is controlling the menu
  • pos (QPoint) – Position on screen
apply_context_menu_action(self, parent, action)[source]

Applies given action from context menu.

Parameters:
  • parent (QWidget) – The widget that is controlling the menu
  • action (str) – The selected action
rename(self, new_name)[source]

Renames this item.

Parameters:new_name (str) – New name
Returns:True if renaming was successful, False if renaming failed
Return type:bool