use product type icon in scene inventory

This commit is contained in:
Jakub Trllo 2025-09-15 11:46:28 +02:00
parent 7b92047a6b
commit cf874e8f0a
3 changed files with 39 additions and 6 deletions

View file

@ -1,3 +1,5 @@
from typing import Optional
import ayon_api
from ayon_core.lib.events import QueuedEventSystem
@ -6,7 +8,11 @@ from ayon_core.pipeline import (
registered_host,
get_current_context,
)
from ayon_core.tools.common_models import HierarchyModel, ProjectsModel
from ayon_core.tools.common_models import (
HierarchyModel,
ProjectsModel,
ProductTypeIconMapping,
)
from .models import SiteSyncModel, ContainersModel
@ -93,6 +99,13 @@ class SceneInventoryController:
project_name, None
)
def get_product_type_icons_mapping(
self, project_name: Optional[str]
) -> ProductTypeIconMapping:
return self._projects_model.get_product_type_icons_mapping(
project_name
)
# Containers methods
def get_containers(self):
return self._containers_model.get_containers()

View file

@ -214,9 +214,6 @@ class InventoryModel(QtGui.QStandardItemModel):
group_icon = qtawesome.icon(
"fa.object-group", color=self._default_icon_color
)
product_type_icon = qtawesome.icon(
"fa.folder", color="#0091B2"
)
group_item_font = QtGui.QFont()
group_item_font.setBold(True)
@ -303,7 +300,7 @@ class InventoryModel(QtGui.QStandardItemModel):
remote_site_progress = "{}%".format(
max(progress["remote_site"], 0) * 100
)
product_type_icon = get_qt_icon(repre_info.product_type_icon)
group_item = QtGui.QStandardItem()
group_item.setColumnCount(root_item.columnCount())
group_item.setData(group_name, QtCore.Qt.DisplayRole)

View file

@ -126,6 +126,7 @@ class RepresentationInfo:
product_id,
product_name,
product_type,
product_type_icon,
product_group,
version_id,
representation_name,
@ -135,6 +136,7 @@ class RepresentationInfo:
self.product_id = product_id
self.product_name = product_name
self.product_type = product_type
self.product_type_icon = product_type_icon
self.product_group = product_group
self.version_id = version_id
self.representation_name = representation_name
@ -153,7 +155,17 @@ class RepresentationInfo:
@classmethod
def new_invalid(cls):
return cls(None, None, None, None, None, None, None, None)
return cls(
None,
None,
None,
None,
None,
None,
None,
None,
None,
)
class VersionItem:
@ -229,6 +241,9 @@ class ContainersModel:
def get_representation_info_items(self, project_name, representation_ids):
output = {}
missing_repre_ids = set()
icons_mapping = self._controller.get_product_type_icons_mapping(
project_name
)
for repre_id in representation_ids:
try:
uuid.UUID(repre_id)
@ -253,6 +268,7 @@ class ContainersModel:
"product_id": None,
"product_name": None,
"product_type": None,
"product_type_icon": None,
"product_group": None,
"version_id": None,
"representation_name": None,
@ -265,10 +281,17 @@ class ContainersModel:
kwargs["folder_id"] = folder["id"]
kwargs["folder_path"] = folder["path"]
if product:
product_type = product["productType"]
product_base_type = product.get("productBaseType")
icon = icons_mapping.get_icon(
product_base_type=product_base_type,
product_type=product_type,
)
group = product["attrib"]["productGroup"]
kwargs["product_id"] = product["id"]
kwargs["product_name"] = product["name"]
kwargs["product_type"] = product["productType"]
kwargs["product_type_icon"] = icon
kwargs["product_group"] = group
if version:
kwargs["version_id"] = version["id"]