loader is using product name and type

This commit is contained in:
Jakub Trllo 2024-02-23 12:29:06 +01:00
parent 8549588f27
commit 2ac1acb19e
4 changed files with 28 additions and 28 deletions

View file

@ -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
))

View file

@ -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(

View file

@ -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(

View file

@ -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
)