python.shotgun_model.shotgun_query_model module¶
-
class
ShotgunQueryModel
(parent, bg_load_thumbs, bg_task_manager=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
A Qt Model base class for querying Shotgun data.
This class is not meant to be used as-is, rather it provides a common interface (methods, signals, etc) for developers to provide across various Shotgun data query models.
Some convenience methods are also provided for handling and manipulating data returned from Shotgun.
Signal Interface
Signal query_changed(): Gets emitted whenever the model’s sg query is changed. When the query changes, the contents of the model is cleared and the loading of new data is initiated. Signal cache_loaded(): Emitted whenever the model loads cache data. This typically follows shortly after a query changed signal, if cache data is available. Signal data_refreshing(): Emitted whenever the model starts to refresh its shotgun data. Useful signal if you want to present a loading indicator of some kind. Signal data_refreshed(bool): Emitted whenever the model has been updated with fresh shotgun data. The boolean indicates that a change in the model data has taken place as part of this process. If the refresh fails for some reason, this signal may not be emitted. Signal data_refresh_fail(str): Emitted in the case the refresh fails for some reason, typically due to the absence of an internet connection. This signal could for example be used to drive a “retry” button of some kind. The str parameter carries an error message with details about why the refresh wasn’t successful. Constants
Constant SG_DATA_ROLE: Custom model role that holds the shotgun data payload Constant IS_SG_MODEL_ROLE: Used to identify model items related to Shotgun data -
IS_SG_MODEL_ROLE
= <MagicMock name='mock()' id='139766413056400'>¶
-
SG_DATA_ROLE
= <MagicMock name='mock()' id='139766413056400'>¶
-
cache_loaded
¶ Used by autodoc_mock_imports.
-
canFetchMore
(index)[source]¶ Returns True if there is more data available for parent; otherwise returns False.
Parameters: index ( QModelIndex
) – The index of the item being tested.
-
clear
()[source]¶ Removes all items (including header items) from the model and sets the number of rows and columns to zero.
-
data_refresh_fail
¶ Used by autodoc_mock_imports.
-
data_refreshed
¶ Used by autodoc_mock_imports.
-
data_refreshing
¶ Used by autodoc_mock_imports.
-
destroy
()[source]¶ Call this method prior to destroying this object.
Base implementation ensures the data worker is stopped and calls
clear()
on the model.
-
fetchMore
(index)[source]¶ Retrieve child items for a node.
Parameters: index ( QModelIndex
) – The index of the item being tested.
-
hasChildren
(index)[source]¶ Returns True if parent has any children; otherwise returns False.
This is used for the staged loading of nodes in hierarchies.
Parameters: index ( QModelIndex
) – The index of the item being tested.
-
is_data_cached
()[source]¶ Determine if the model has any cached data.
Returns: True
if cached data exists for the model,False
otherwise.
-
query_changed
¶ Used by autodoc_mock_imports.
-
reset
()[source]¶ Re-implements QAbstractItemModel:reset() by ‘sealing it’ so that it cannot be executed by calling code easily. This is because the reset method often results in crashes and instability because of how PySide/Qt manages memory.
For more information, see the clear() method in
ShotgunModel
.
-