python.shotgun_model.shotgun_hierarchy_model module

class ShotgunHierarchyModel(parent, schema_generation=0, bg_task_manager=None, include_root=None)[source]

Bases: python.shotgun_model.shotgun_query_model.ShotgunQueryModel

A Qt Model representing a Shotgun hierarchy.

Warning

Use of this model requires version Shotgun v7.0.2 or later. Attempts to construct an instance of this model on an older version of Shotgun will result with a single item in the model saying that Hierarchy model isn’t supported. A warning will also be logged.

This class implements a standard QAbstractItemModel specialized to hold the contents of a particular Shotgun query. It is cached and refreshes its data asynchronously.

In order to use this class, you normally subclass it and implement certain key data methods for setting up queries, customizing etc. Then you connect your class to a QAbstractItemView of some sort which will display the result.

The model stores a single column, lazy-loaded Shotgun Hierarchy as queried via the nav_expand() python-api method. The structure of items in the hierarchy mimics what is found in Shotgun as configured in each project’s Tracking Settings.

Signal:async_item_retrieval_completed (ShotgunHierarchyModel): Emitted when a query to ShotgunHierarchyModel.async_item_from_entity() or ShotgunHierarchyModel.async_item_from_paths() has completed.
async_item_from_entity(entity)[source]

Asynchronously loads an entity’s node and all its parents and emits a signal with the associated ShotgunHierarchyItem when the node is loaded.

Parameters:entity (dict) – Entity dictionary with keys type and id.
Signals:async_item_retrieval_completed
async_item_from_paths(paths)[source]

Takes a list of paths that incrementally dig deeper into the model and signals when the node is found and loaded in memory.

Parameters:list(str) – List of paths from the nav api that drill down further and further into the tree.
Signals:async_item_retrieval_completed
async_item_retrieval_completed

Used by autodoc_mock_imports.

fetchMore(index)[source]

Retrieve child items for a node.

Parameters:index (QModelIndex) – The index of the item being tested.
item_from_path(path)[source]

Returns a QStandardItem for the supplied path.

Returns None if not found.

Parameters:path (str) – The path to search the tree for. The paths match those used by and returned from the python-api’s nav_expand() method.
Returns:QStandardItem or None if not found