items.file_items#
File items are files found inside an asset item. They’re made up of server
,
job
, root
, asset
, task
and file
path segments.
1# The following file path...
2my_file = '//my/server/my_job/my_asset/my_task_folder/take1/my_file.psd
3# ...is constructed like this:
4my_file = f'{server}/{job}/{root}/{asset}/{task}/take1/my_file.psd'
5# Note the relative path segment ``take1/my_file.psd``
Note the two new path segments file items introduce: task
items, and a relative
file segment, take1/my_file.psd
.
FileItemModel
will always load recursively all files found in a specified
task folder. In the real world, these correspond to workspace folders used by DCCs,
such as the scenes, cache, images, render, etc. folders. These folders are the
main containers for file items.
FileItemModel
will always load files from inside the active task folder. We
set the active task folder using TaskItemView
.
The relative file path segment is what FileItemView
displays.
This segment often includes a series of subdirectories the view represents as
interactive labels. These labels can be used to filter the list view.
Note
In summary , FileItemModel
will not load file items from the root
of an asset item, but from subdirectories called task
items. It will load
all files from all subdirectories from this folder but provides filter options in the
form of interactive labels.
Important to note that FileItemModel
interacts with two data sets
simultaneously: a collapsed sequence and a regular file data set.
See the sequence
module for details on sequence definitions, and
model_data()
.
Classes:
|
Model used to list files in an asset. |
|
The view used to display |
|
Context menu associated with |
Functions:
|
Returns the path elements needed to populate the file item model data. |
|
cache-backed utility function to retrieve the sequence elements from the given file path. |
- class bookmarks.items.file_items.FileItemModel(parent=None)[source]#
Bases:
ItemModel
Model used to list files in an asset.
The model will load files from one task folder at any given time. The current task folder can be retrieved by
task()
. Switching tasks is done via emitting thetaskFolderChanged
signals.The model will load the found files into two separate data sets, one listing files individually, the other groups them into sequences. See
bookmarks.common.sequences
for the rules that determine how sequence items are identified.Switching between FileItems and SequenceItems is done by emitting the
dataTypeChanged
signal.Note
The model won’t necessarily load all files it encounters. If the parent bookmark item has a valid token config set, certain file extension might be excluded. See the
bookmarks.tokens.tokens
for details.Methods:
Data type refers to the internal data set exposed to the model.
Overrides the token config and disables file filters.
The custom dictionary key used to save filter settings to the user settings file.
init_data
(**kwargs)Function wrapper.
item_generator
(path)Recursive iterator for retrieving files from all task sub-folders.
mimeData
(indexes)The data necessary for supporting drag and drop operations are constructed here.
Returns the refresh states of the current model data set.
Saves the current active item.
set_data_type
(val)Set the model's data type.
Sets the refresh status of the current model data set.
The model's parent folder path segments.
task
()The model's associated task.
- data_type()[source]#
Data type refers to the internal data set exposed to the model.
We have two types implemented: A FileItem type and a SequenceItem type. The latter is used to display image sequences as single collapsed items.
The type can be toggled with the dataTypeChanged signal.
- filter_setting_dict_key()[source]#
The custom dictionary key used to save filter settings to the user settings file.
- init_data(**kwargs)#
Function wrapper.
- mimeData(indexes)[source]#
The data necessary for supporting drag and drop operations are constructed here.
There is ambiguity in the absence of any good documentation I could find regarding what mime types have to be defined exactly for fully supporting drag and drop on all platforms.
Note
On Windows,
application/x-qt-windows-mime;value="FileName"
andapplication/x-qt-windows-mime;value="FileNameW"
types seems to be necessary, but on macOS a simple uri list seem to suffice.
- set_data_type(val)[source]#
Set the model’s data type.
The model can serv items as collapsed sequence items, or as standard, individual file items. When the data type is set to
common.SequenceItem
file sequences will be collapsed into a single sequence item. When the data type iscommon.FileItem
each item will be displayed individually.In practice only
FileItemModel
implements collapsedcommon.SequenceItem
items.- Parameters:
val (int) – A data type, one of
common.FileItem
,common.SequenceItem
.
- class bookmarks.items.file_items.FileItemView(icon='file', parent=None)[source]#
Bases:
ThreadedItemView
The view used to display
FileItemModel
items.Classes:
alias of
FileItemViewContextMenu
alias of
FileItemViewDelegate
Methods:
Returns an informative hint text.
Returns the model class associated with this view.
Inline buttons count.
Custom key action.
show_item
(v[, role, update, limit])This slot is called by the itemAdded signal.
- ContextMenu#
alias of
FileItemViewContextMenu
Methods:setup
()Creates the context menu.
- Delegate#
alias of
FileItemViewDelegate
Methods:paint
(painter, option, index)Paints a
bookmarks.items.file_items.FileItemView
item.sizeHint
(option, index)Returns the item's size hint.
Attributes:
fallback_thumb
The item's default thumbnail image
- class bookmarks.items.file_items.FileItemViewContextMenu(index, parent=None)[source]#
Bases:
BaseContextMenu
Context menu associated with
FileItemView
.Methods:
setup
()Creates the context menu.
- bookmarks.items.file_items.get_path_elements(p, k, name, path, source_path)[source]#
Returns the path elements needed to populate the file item model data.
- Parameters:
p (tuple) – Parent path elements.
k (str) – Task folder.
name (str) – File name.
path (str) – File path.
source_path (str) – File source path.
- Returns:
Tuple of path, ext, file_root, dir, sort_by_name_role.
- Return type:
tuple