mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
products model fills statuses for filtering
This commit is contained in:
parent
35e55a234f
commit
75e5c4a9fe
1 changed files with 27 additions and 10 deletions
|
|
@ -39,6 +39,8 @@ REPRESENTATIONS_COUNT_ROLE = QtCore.Qt.UserRole + 28
|
|||
SYNC_ACTIVE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 29
|
||||
SYNC_REMOTE_SITE_AVAILABILITY = QtCore.Qt.UserRole + 30
|
||||
|
||||
STATUS_NAME_FILTER_ROLE = QtCore.Qt.UserRole + 31
|
||||
|
||||
|
||||
class ProductsModel(QtGui.QStandardItemModel):
|
||||
refreshed = QtCore.Signal()
|
||||
|
|
@ -105,7 +107,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
}
|
||||
|
||||
def __init__(self, controller):
|
||||
super(ProductsModel, self).__init__()
|
||||
super().__init__()
|
||||
self.setColumnCount(len(self.column_labels))
|
||||
for idx, label in enumerate(self.column_labels):
|
||||
self.setHeaderData(idx, QtCore.Qt.Horizontal, label)
|
||||
|
|
@ -163,7 +165,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
)
|
||||
if index.column() != 0:
|
||||
index = self.index(index.row(), 0, index.parent())
|
||||
return super(ProductsModel, self).flags(index)
|
||||
return super().flags(index)
|
||||
|
||||
def data(self, index, role=None):
|
||||
if role is None:
|
||||
|
|
@ -190,7 +192,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
return self._get_status_icon(status_name)
|
||||
|
||||
if col == 0:
|
||||
return super(ProductsModel, self).data(index, role)
|
||||
return super().data(index, role)
|
||||
|
||||
if role == QtCore.Qt.DecorationRole:
|
||||
if col == 1:
|
||||
|
|
@ -223,7 +225,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
|
||||
index = self.index(index.row(), 0, index.parent())
|
||||
|
||||
return super(ProductsModel, self).data(index, role)
|
||||
return super().data(index, role)
|
||||
|
||||
def setData(self, index, value, role=None):
|
||||
if not index.isValid():
|
||||
|
|
@ -255,7 +257,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
self._set_version_data_to_product_item(item, final_version_item)
|
||||
self.version_changed.emit()
|
||||
return True
|
||||
return super(ProductsModel, self).setData(index, value, role)
|
||||
return super().setData(index, value, role)
|
||||
|
||||
def _get_next_color(self):
|
||||
return next(self._color_iterator)
|
||||
|
|
@ -401,6 +403,10 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
versions = list(product_item.version_items.values())
|
||||
versions.sort()
|
||||
last_version = versions[-1]
|
||||
statuses = {
|
||||
version_item.status
|
||||
for version_item in product_item.version_items.values()
|
||||
}
|
||||
if model_item is None:
|
||||
product_id = product_item.product_id
|
||||
model_item = QtGui.QStandardItem(product_item.product_name)
|
||||
|
|
@ -418,6 +424,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
self._product_items_by_id[product_id] = product_item
|
||||
self._items_by_id[product_id] = model_item
|
||||
|
||||
model_item.setData("|".join(statuses), STATUS_NAME_FILTER_ROLE)
|
||||
model_item.setData(product_item.folder_label, FOLDER_LABEL_ROLE)
|
||||
in_scene = 1 if product_item.product_in_scene else 0
|
||||
model_item.setData(in_scene, PRODUCT_IN_SCENE_ROLE)
|
||||
|
|
@ -494,10 +501,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
|
||||
product_name = product_item.product_name
|
||||
group = product_name_matches_by_group[group_name]
|
||||
if product_name not in group:
|
||||
group[product_name] = [product_item]
|
||||
continue
|
||||
group[product_name].append(product_item)
|
||||
group.setdefault(product_name, []).append(product_item)
|
||||
|
||||
group_names = set(product_name_matches_by_group.keys())
|
||||
|
||||
|
|
@ -513,8 +517,15 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
merged_product_items = {}
|
||||
top_items = []
|
||||
group_product_types = set()
|
||||
group_status_names = set()
|
||||
for product_name, product_items in groups.items():
|
||||
group_product_types |= {p.product_type for p in product_items}
|
||||
for product_item in product_items:
|
||||
group_product_types |= {
|
||||
version_item.status
|
||||
for version_item in product_item.version_items.values()
|
||||
}
|
||||
|
||||
if len(product_items) == 1:
|
||||
top_items.append(product_items[0])
|
||||
else:
|
||||
|
|
@ -529,7 +540,13 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
if group_name:
|
||||
parent_item = self._get_group_model_item(group_name)
|
||||
parent_item.setData(
|
||||
"|".join(group_product_types), PRODUCT_TYPE_ROLE)
|
||||
"|".join(group_product_types),
|
||||
PRODUCT_TYPE_ROLE
|
||||
)
|
||||
parent_item.setData(
|
||||
"|".join(group_status_names),
|
||||
STATUS_NAME_FILTER_ROLE
|
||||
)
|
||||
|
||||
new_items = []
|
||||
if parent_item is not None and parent_item.row() < 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue