From 2ac1acb19e8ef10fa5ca35b659f17920102f8f56 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 23 Feb 2024 12:29:06 +0100 Subject: [PATCH] loader is using product name and type --- .../ayon_core/tools/loader/models/actions.py | 12 ++++---- .../tools/loader/models/site_sync.py | 12 ++++---- .../tools/loader/ui/folders_widget.py | 30 +++++++++---------- .../tools/loader/ui/products_widget.py | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/client/ayon_core/tools/loader/models/actions.py b/client/ayon_core/tools/loader/models/actions.py index c70ccb3e18..dff15ea16c 100644 --- a/client/ayon_core/tools/loader/models/actions.py +++ b/client/ayon_core/tools/loader/models/actions.py @@ -809,10 +809,10 @@ class LoaderActionsModel: error_info = [] if loader.is_multiple_contexts_compatible: - subset_names = [] + product_names = [] for context in version_contexts: - subset_name = context.get("subset", {}).get("name") or "N/A" - subset_names.append(subset_name) + product_name = context.get("subset", {}).get("name") or "N/A" + product_names.append(product_name) try: load_with_subset_contexts( loader, @@ -831,12 +831,12 @@ class LoaderActionsModel: str(exc), formatted_traceback, None, - ", ".join(subset_names), + ", ".join(product_names), None )) else: for version_context in version_contexts: - subset_name = ( + product_name = ( version_context.get("subset", {}).get("name") or "N/A" ) try: @@ -860,7 +860,7 @@ class LoaderActionsModel: str(exc), formatted_traceback, None, - subset_name, + product_name, None )) diff --git a/client/ayon_core/tools/loader/models/site_sync.py b/client/ayon_core/tools/loader/models/site_sync.py index e6158ea280..2a6f1558ad 100644 --- a/client/ayon_core/tools/loader/models/site_sync.py +++ b/client/ayon_core/tools/loader/models/site_sync.py @@ -325,21 +325,21 @@ class SiteSyncModel: repre_docs = list(get_representations( project_name, representation_ids=representation_ids )) - families_per_repre_id = { + product_type_by_repre_id = { item["_id"]: item["context"]["family"] for item in repre_docs } for repre_id in representation_ids: - family = families_per_repre_id[repre_id] + product_type = product_type_by_repre_id[repre_id] if identifier == DOWNLOAD_IDENTIFIER: self._add_site( - project_name, repre_id, active_site, family + project_name, repre_id, active_site, product_type ) elif identifier == UPLOAD_IDENTIFIER: self._add_site( - project_name, repre_id, remote_site, family + project_name, repre_id, remote_site, product_type ) elif identifier == REMOVE_IDENTIFIER: @@ -485,13 +485,13 @@ class SiteSyncModel: representation_ids=representation_ids, ) - def _add_site(self, project_name, repre_id, site_name, family): + def _add_site(self, project_name, repre_id, site_name, product_type): self._site_sync_addon.add_site( project_name, repre_id, site_name, force=True ) # TODO this should happen in site sync addon - if family != "workfile": + if product_type != "workfile": return links = get_linked_representation_id( diff --git a/client/ayon_core/tools/loader/ui/folders_widget.py b/client/ayon_core/tools/loader/ui/folders_widget.py index 9d5b95b2a6..34881ab49d 100644 --- a/client/ayon_core/tools/loader/ui/folders_widget.py +++ b/client/ayon_core/tools/loader/ui/folders_widget.py @@ -56,34 +56,34 @@ class UnderlinesFolderDelegate(QtWidgets.QItemDelegate): item_rect = QtCore.QRect(option.rect) item_rect.setHeight(option.rect.height() - self.bar_height) - subset_colors = index.data(UNDERLINE_COLORS_ROLE) or [] + product_colors = index.data(UNDERLINE_COLORS_ROLE) or [] - subset_colors_width = 0 - if subset_colors: - subset_colors_width = option.rect.width() / len(subset_colors) + product_colors_width = 0 + if product_colors: + product_colors_width = option.rect.width() / len(product_colors) - subset_rects = [] + product_rects = [] counter = 0 - for subset_c in subset_colors: + for product_c in product_colors: new_color = None new_rect = None - if subset_c: - new_color = QtGui.QColor(subset_c) + if product_c: + new_color = QtGui.QColor(product_c) new_rect = QtCore.QRect( - option.rect.left() + (counter * subset_colors_width), + option.rect.left() + (counter * product_colors_width), option.rect.top() + ( option.rect.height() - self.bar_height ), - subset_colors_width, + product_colors_width, self.bar_height ) - subset_rects.append((new_color, new_rect)) + product_rects.append((new_color, new_rect)) counter += 1 # Background if option.state & QtWidgets.QStyle.State_Selected: - if len(subset_colors) == 0: + if len(product_colors) == 0: item_rect.setTop(item_rect.top() + (self.bar_height / 2)) if option.state & QtWidgets.QStyle.State_MouseOver: @@ -106,10 +106,10 @@ class UnderlinesFolderDelegate(QtWidgets.QItemDelegate): ) if option.state & QtWidgets.QStyle.State_Selected: - for color, subset_rect in subset_rects: - if not color or not subset_rect: + for color, product_rect in product_rects: + if not color or not product_rect: continue - painter.fillRect(subset_rect, QtGui.QBrush(color)) + painter.fillRect(product_rect, QtGui.QBrush(color)) # Icon icon_index = index.model().index( diff --git a/client/ayon_core/tools/loader/ui/products_widget.py b/client/ayon_core/tools/loader/ui/products_widget.py index 5a29f3f762..3025ec18bd 100644 --- a/client/ayon_core/tools/loader/ui/products_widget.py +++ b/client/ayon_core/tools/loader/ui/products_widget.py @@ -106,7 +106,7 @@ class ProductsWidget(QtWidgets.QWidget): products_view = DeselectableTreeView(self) # TODO - define custom object name in style - products_view.setObjectName("SubsetView") + products_view.setObjectName("ProductView") products_view.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection )