python.shotgun_model.shotgun_model module¶
-
class
ShotgunModel
(parent, download_thumbs=True, schema_generation=0, bg_load_thumbs=True, bg_task_manager=None)[source]¶ Bases:
python.shotgun_model.shotgun_query_model.ShotgunQueryModel
A Qt Model representing a Shotgun query.
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. If you need to do manipulations such as sorting or filtering on the data, connect a proxy model (typicallyQSortFilterProxyModel
) between your class and the view.-
DATA_HANDLER_CLASS
¶ alias of
python.shotgun_model.data_handler_find.ShotgunFindDataHandler
-
FIRST_COLUMN_HEADER
= 'Name'¶
-
SG_ASSOCIATED_FIELD_ROLE
= <MagicMock name='mock()' id='139766413056400'>¶
-
ensure_data_is_loaded
(index=None)[source]¶ Recursively processes the model and ensures that all data has been loaded into the model.
Beginning with v5, the Shotgun model defer loads its data into the model for optimal performance. Normally, this is not an issue - the data is typically requested prior to a user expanding a tree node in a view. In some cases, however, it is necessary to pre-fetch parts of the tree. One example of this is if you want to perform filtering via a
QSortFilterProxyModel
. Please note that for large data sets, this operation may be slow.New in version 5.0.0.
Parameters: index ( QModelIndex
) – Model index for which to recursively load data. If set to None, the entire tree will be loaded.
-
entity_ids
¶ Returns a list of entity ids that are part of this model.
-
get_additional_column_fields
()[source]¶ Returns the fields for additional columns and their associated column in the model.
Returns: A list of dictionaries with the following keys: “field”: the requested additional field for the column “column_idx”: the column number in the model associated with the additional field
-
get_entity_type
()[source]¶ Returns the Shotgun Entity type associated with this model.
Returns: Shotgun entity type string (e.g. ‘Shot’, ‘Asset’ etc).
-
get_filters
(item)[source]¶ Returns a list of Shotgun filters representing the given item. This is useful if you are trying to determine how intermediate leaf nodes partition leaf node data.
For example, if you have created a hierarchical model for a Shot listing:
hierarchy: [sg_sequence, sg_status, code]
The Shotgun model will group the data by sequence, then by status, then the leaf nodes will be the shot names. If you execute the get_filters() method on a sequence level tree node, it may return:
[ ['sg_sequence', 'is', {'type': 'Sequence', 'id': 123, 'name': 'foo'}] ]
If you execute the get_filters() on a status node in the tree, it may return:
[ ['sg_sequence', 'is', {'type': 'Sequence', 'id': 123, 'name': 'foo'}], ['sg_status', 'is', 'ip'] ]
Parameters: item – One of the QStandardItem
items that are associated with this model.Returns: standard shotgun filter list to represent that item
-
index_from_entity
(entity_type, entity_id)[source]¶ Returns a QModelIndex based on entity type and entity id Returns none if not found.
Parameters: - entity_type – Shotgun entity type to look for
- entity_id – Shotgun entity id to look for
Returns: QModelIndex
or None if not found
-
item_from_entity
(entity_type, entity_id)[source]¶ Returns a
QStandardItem
based on entity type and entity id. Returns none if not found.Parameters: - entity_type – Shotgun entity type to look for
- entity_id – Shotgun entity id to look for
Returns: QStandardItem
or None if not found
-