show product base type in the loader

This commit is contained in:
Ondřej Samohel 2025-06-06 14:03:31 +02:00
parent 6ea717bc36
commit 3a2f470dce
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
4 changed files with 55 additions and 29 deletions

View file

@ -1,14 +1,15 @@
"""Abstract base classes for loader tool."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List, Optional, TypedDict
from ayon_core.lib.attribute_definitions import (
AbstractAttrDef,
serialize_attr_defs,
deserialize_attr_defs,
serialize_attr_defs,
)
IconData = TypedDict("IconData", {
"type": str,
"name": str,
@ -80,20 +81,37 @@ class ProductTypeItem:
class ProductBaseTypeItem:
"""Item representing product base type."""
"""Item representing the product base type."""
def __init__(self, name: str, icon: IconData):
"""Initialize product base type item."""
self.name = name
self.icon = icon
def to_data(self) -> ProductBaseTypeItemData:
"""Convert item to data dictionary.
Returns:
ProductBaseTypeItemData: Data representation of the item.
"""
return {
"name": self.name,
"icon": self.icon,
}
@classmethod
def from_data(cls, data: ProductBaseTypeItemData):
def from_data(
cls, data: ProductBaseTypeItemData) -> ProductBaseTypeItem:
"""Create item from data dictionary.
Args:
data (ProductBaseTypeItemData): Data to create item from.
Returns:
ProductBaseTypeItem: Item created from the provided data.
"""
return cls(**data)

View file

@ -270,7 +270,7 @@ class ProductsModel:
def get_product_base_type_items(
self,
project_name: Optional[str]) -> list[ProductBaseTypeItem]:
"""Product base type items for project.
"""Product base type items for the project.
Args:
project_name (optional, str): Project name.

View file

@ -16,31 +16,32 @@ TASK_ID_ROLE = QtCore.Qt.UserRole + 5
PRODUCT_ID_ROLE = QtCore.Qt.UserRole + 6
PRODUCT_NAME_ROLE = QtCore.Qt.UserRole + 7
PRODUCT_TYPE_ROLE = QtCore.Qt.UserRole + 8
PRODUCT_TYPE_ICON_ROLE = QtCore.Qt.UserRole + 9
PRODUCT_IN_SCENE_ROLE = QtCore.Qt.UserRole + 10
VERSION_ID_ROLE = QtCore.Qt.UserRole + 11
VERSION_HERO_ROLE = QtCore.Qt.UserRole + 12
VERSION_NAME_ROLE = QtCore.Qt.UserRole + 13
VERSION_NAME_EDIT_ROLE = QtCore.Qt.UserRole + 14
VERSION_PUBLISH_TIME_ROLE = QtCore.Qt.UserRole + 15
VERSION_STATUS_NAME_ROLE = QtCore.Qt.UserRole + 16
VERSION_STATUS_SHORT_ROLE = QtCore.Qt.UserRole + 17
VERSION_STATUS_COLOR_ROLE = QtCore.Qt.UserRole + 18
VERSION_STATUS_ICON_ROLE = QtCore.Qt.UserRole + 19
VERSION_AUTHOR_ROLE = QtCore.Qt.UserRole + 20
VERSION_FRAME_RANGE_ROLE = QtCore.Qt.UserRole + 21
VERSION_DURATION_ROLE = QtCore.Qt.UserRole + 22
VERSION_HANDLES_ROLE = QtCore.Qt.UserRole + 23
VERSION_STEP_ROLE = QtCore.Qt.UserRole + 24
VERSION_AVAILABLE_ROLE = QtCore.Qt.UserRole + 25
VERSION_THUMBNAIL_ID_ROLE = QtCore.Qt.UserRole + 26
ACTIVE_SITE_ICON_ROLE = QtCore.Qt.UserRole + 27
REMOTE_SITE_ICON_ROLE = QtCore.Qt.UserRole + 28
REPRESENTATIONS_COUNT_ROLE = QtCore.Qt.UserRole + 29
SYNC_ACTIVE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 30
SYNC_REMOTE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 31
PRODUCT_BASE_TYPE_ROLE = QtCore.Qt.UserRole + 9
PRODUCT_TYPE_ICON_ROLE = QtCore.Qt.UserRole + 10
PRODUCT_IN_SCENE_ROLE = QtCore.Qt.UserRole + 11
VERSION_ID_ROLE = QtCore.Qt.UserRole + 12
VERSION_HERO_ROLE = QtCore.Qt.UserRole + 13
VERSION_NAME_ROLE = QtCore.Qt.UserRole + 14
VERSION_NAME_EDIT_ROLE = QtCore.Qt.UserRole + 15
VERSION_PUBLISH_TIME_ROLE = QtCore.Qt.UserRole + 16
VERSION_STATUS_NAME_ROLE = QtCore.Qt.UserRole + 17
VERSION_STATUS_SHORT_ROLE = QtCore.Qt.UserRole + 18
VERSION_STATUS_COLOR_ROLE = QtCore.Qt.UserRole + 19
VERSION_STATUS_ICON_ROLE = QtCore.Qt.UserRole + 20
VERSION_AUTHOR_ROLE = QtCore.Qt.UserRole + 21
VERSION_FRAME_RANGE_ROLE = QtCore.Qt.UserRole + 22
VERSION_DURATION_ROLE = QtCore.Qt.UserRole + 23
VERSION_HANDLES_ROLE = QtCore.Qt.UserRole + 24
VERSION_STEP_ROLE = QtCore.Qt.UserRole + 25
VERSION_AVAILABLE_ROLE = QtCore.Qt.UserRole + 26
VERSION_THUMBNAIL_ID_ROLE = QtCore.Qt.UserRole + 27
ACTIVE_SITE_ICON_ROLE = QtCore.Qt.UserRole + 28
REMOTE_SITE_ICON_ROLE = QtCore.Qt.UserRole + 29
REPRESENTATIONS_COUNT_ROLE = QtCore.Qt.UserRole + 30
SYNC_ACTIVE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 31
SYNC_REMOTE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 32
STATUS_NAME_FILTER_ROLE = QtCore.Qt.UserRole + 32
STATUS_NAME_FILTER_ROLE = QtCore.Qt.UserRole + 33
class ProductsModel(QtGui.QStandardItemModel):
@ -49,6 +50,7 @@ class ProductsModel(QtGui.QStandardItemModel):
column_labels = [
"Product name",
"Product type",
"Product base type",
"Folder",
"Version",
"Status",
@ -79,6 +81,7 @@ class ProductsModel(QtGui.QStandardItemModel):
product_name_col = column_labels.index("Product name")
product_type_col = column_labels.index("Product type")
product_base_type_col = column_labels.index("Product base type")
folders_label_col = column_labels.index("Folder")
version_col = column_labels.index("Version")
status_col = column_labels.index("Status")
@ -93,6 +96,7 @@ class ProductsModel(QtGui.QStandardItemModel):
_display_role_mapping = {
product_name_col: QtCore.Qt.DisplayRole,
product_type_col: PRODUCT_TYPE_ROLE,
product_base_type_col: PRODUCT_BASE_TYPE_ROLE,
folders_label_col: FOLDER_LABEL_ROLE,
version_col: VERSION_NAME_ROLE,
status_col: VERSION_STATUS_NAME_ROLE,
@ -432,6 +436,9 @@ class ProductsModel(QtGui.QStandardItemModel):
model_item.setData(icon, QtCore.Qt.DecorationRole)
model_item.setData(product_id, PRODUCT_ID_ROLE)
model_item.setData(product_item.product_name, PRODUCT_NAME_ROLE)
model_item.setData(
product_item.product_base_type, PRODUCT_BASE_TYPE_ROLE
)
model_item.setData(product_item.product_type, PRODUCT_TYPE_ROLE)
model_item.setData(product_type_icon, PRODUCT_TYPE_ICON_ROLE)
model_item.setData(product_item.folder_id, FOLDER_ID_ROLE)

View file

@ -142,6 +142,7 @@ class ProductsWidget(QtWidgets.QWidget):
default_widths = (
200, # Product name
90, # Product type
90, # Product base type
130, # Folder label
60, # Version
100, # Status