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:

FileItemModel([parent])

Model used to list files in an asset.

FileItemView([icon, parent])

The view used to display FileItemModel items.

FileItemViewContextMenu(index[, parent])

Context menu associated with FileItemView.

Functions:

get_path_elements(p, k, name, path, source_path)

Returns the path elements needed to populate the file item model data.

get_sequence_elements(filepath)

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 the taskFolderChanged 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()

Data type refers to the internal data set exposed to the model.

disable_filter()

Overrides the token config and disables file filters.

filter_setting_dict_key()

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.

refresh_needed()

Returns the refresh states of the current model data set.

save_active()

Saves the current active item.

set_data_type(val)

Set the model's data type.

set_refresh_needed(v)

Sets the refresh status of the current model data set.

source_path()

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.

disable_filter()[source]#

Overrides the token config and disables file filters.

filter_setting_dict_key()[source]#

The custom dictionary key used to save filter settings to the user settings file.

init_data(**kwargs)#

Function wrapper.

item_generator(path)[source]#

Recursive iterator for retrieving files from all task sub-folders.

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" and application/x-qt-windows-mime;value="FileNameW" types seems to be necessary, but on macOS a simple uri list seem to suffice.

refresh_needed()[source]#

Returns the refresh states of the current model data set.

save_active()[source]#

Saves the current active item.

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 is common.FileItem each item will be displayed individually.

In practice only FileItemModel implements collapsed common.SequenceItem items.

Parameters:

val (int) – A data type, one of common.FileItem, common.SequenceItem.

set_refresh_needed(v)[source]#

Sets the refresh status of the current model data set.

source_path()[source]#

The model’s parent folder path segments.

Returns:

A tuple of path segments.

Return type:

tuple

task()[source]#

The model’s associated task.

class bookmarks.items.file_items.FileItemView(icon='file', parent=None)[source]#

Bases: ThreadedItemView

The view used to display FileItemModel items.

Classes:

Methods:

get_hint_string()

Returns an informative hint text.

get_source_model()

Returns the model class associated with this view.

inline_icons_count()

Inline buttons count.

key_enter()

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

get_hint_string()[source]#

Returns an informative hint text.

get_source_model()[source]#

Returns the model class associated with this view.

inline_icons_count()[source]#

Inline buttons count.

key_enter()[source]#

Custom key action.

show_item(v, role=QtCore.Qt.DisplayRole, update=True, limit=10000)[source]#

This slot is called by the itemAdded signal.

For instance, when new file is added we’ll use this method to reveal it in the files tab.

class bookmarks.items.file_items.FileItemViewContextMenu(index, parent=None)[source]#

Bases: BaseContextMenu

Context menu associated with FileItemView.

Methods:

setup()

Creates the context menu.

setup()[source]#

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

bookmarks.items.file_items.get_sequence_elements(filepath)[source]#

cache-backed utility function to retrieve the sequence elements from the given file path.

Parameters:

filepath (str) – A file path.

Returns:

The regex match instance and a proxy sequence path.