Skip to content

Conversation

@FuzzkingCool
Copy link
Contributor

Changelog Description

This pull request introduces a new feature to the Scene Inventory tool: the ability to group items by product group, improving organization and usability. It adds a UI checkbox to enable or disable grouping, updates the model and view logic to support both grouped and flat item structures, and refactors related methods for batch update.

Feature: Grouping by Product Group

  • Added a grouping_checkbox to the UI in window.py, allowing users to toggle grouping of items by product group. This includes connecting its state change to the appropriate handler and updating the layout. [1] [2] [3] [4]
  • Implemented grouping logic in the model: added _grouping_enabled state, a set_enable_grouping method, and a _create_grouped_items helper to build the grouped item hierarchy. The model's refresh method now supports both grouped and flat structures based on the grouping setting. [1] [2] [3]
image P.S. Ignore my "renderlayer" product type as its specific to our pipeline.

Additional info

Integration with View

  • Added set_enable_grouping to the view class to propagate the grouping state from the UI to the model.

Refactoring and Bug Fixes

  • Refactored several code blocks in model.py for clarity and consistency, including dictionary initializations, item construction, and data assignments to ensure correct behavior in both grouped and flat modes. [1] [2] [3] [4] [5] [6]

Refactored Item Detection considering groups possibility

  • Enhanced get_outdated_item_ids to recursively traverse the model hierarchy, ensuring outdated items are correctly identified in both grouped and flat structures. [1] [2]

Testing notes:

  1. Launch a file with a set of containers with the same productGroup in any host integration, and some loose ones to test as well.
  2. Open Scene Inventory, and confirm the toggle for grouping works. Observe grouping. Test batch update as the hierarchy is different now/

FuzzkingCool and others added 4 commits October 30, 2025 15:30
- Introduced a new grouping feature in the InventoryModel to allow items to be organized by product group.
- Added a method `set_enable_grouping` to toggle grouping on and off.
- Updated the SceneInventoryView to include a checkbox for enabling grouping.
- Modified the SceneInventoryWindow to include the grouping checkbox and its state change handling.
- Removed unnecessary loops for checking group items and hero items.
- Simplified the collection of outdated container IDs from the full hierarchy.
- Added filtering to exclude None values from the returned list of outdated item IDs.
@ynbot ynbot added the size/M label Oct 30, 2025
@BigRoy BigRoy requested a review from iLLiCiTiT October 30, 2025 20:52
@BigRoy BigRoy added community Issues and PRs coming from the community members type: enhancement Improvement of existing functionality or minor addition labels Oct 30, 2025
is_hero = False
status_name = None
else:
# Flat structure (original behavior)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else really deserves a separate method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question, how much are those 2 different? Isn't it that one just adds one more parent? Wouldn't be easier to handle that in single method instead of having 2 huge methods with most of the code duplicated?

item_by_repre_id_by_project
[project_name]
[representation_id]
item_by_repre_id_by_project[project_name][representation_id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
item_by_repre_id_by_project[project_name][representation_id]
item_by_repre_id_by_project
[project_name]
[representation_id]

Comment on lines 434 to 457
def collect_outdated_from_item(parent_item):
"""Recursively collect outdated container item IDs."""
for row in range(parent_item.rowCount()):
item = parent_item.child(row)

# Check if this is an actual container item
is_container = item.data(IS_CONTAINER_ITEM_ROLE)

if is_container:
# This is a container - check if it's outdated
is_latest = item.data(VERSION_IS_LATEST_ROLE)
is_hero = item.data(VERSION_IS_HERO_ROLE)

for idx in range(group_item.rowCount()):
item = group_item.child(idx)
outdated_item_ids.append(item.data(ITEM_ID_ROLE))
return outdated_item_ids
if not is_latest and not (ignore_hero and is_hero):
item_id = item.data(ITEM_ID_ROLE)
if item_id:
outdated_item_ids.append(item_id)
else:
# This is a group item - recurse into its children
collect_outdated_from_item(item)

root_item = self.invisibleRootItem()
# Collect outdated container ids from the full hierarchy
collect_outdated_from_item(root_item)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def collect_outdated_from_item(parent_item):
"""Recursively collect outdated container item IDs."""
for row in range(parent_item.rowCount()):
item = parent_item.child(row)
# Check if this is an actual container item
is_container = item.data(IS_CONTAINER_ITEM_ROLE)
if is_container:
# This is a container - check if it's outdated
is_latest = item.data(VERSION_IS_LATEST_ROLE)
is_hero = item.data(VERSION_IS_HERO_ROLE)
for idx in range(group_item.rowCount()):
item = group_item.child(idx)
outdated_item_ids.append(item.data(ITEM_ID_ROLE))
return outdated_item_ids
if not is_latest and not (ignore_hero and is_hero):
item_id = item.data(ITEM_ID_ROLE)
if item_id:
outdated_item_ids.append(item_id)
else:
# This is a group item - recurse into its children
collect_outdated_from_item(item)
root_item = self.invisibleRootItem()
# Collect outdated container ids from the full hierarchy
collect_outdated_from_item(root_item)
root_item = self.invisibleRootItem()
parent_queue = collections.deque()
parent_queue.append(root_item)
while parent_queue:
parent_item = parent_queue.popleft()
for row in range(parent_item.rowCount()):
item = parent_item.child(row)
# Check if this is an actual container item
is_container = item.data(IS_CONTAINER_ITEM_ROLE)
if not is_container:
parent_queue.append(item)
continue
# This is a container - check if it's outdated
if (
item.data(VERSION_IS_LATEST_ROLE)
or item.data(VERSION_IS_HERO_ROLE)
):
continue
item_id = item.data(ITEM_ID_ROLE)
if item_id:
outdated_item_ids.append(item_id)

# Collect outdated container ids from the full hierarchy
collect_outdated_from_item(root_item)
# Filter out any None values (e.g. from non-container rows)
return [item_id for item_id in outdated_item_ids if item_id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for item id already happens to be appended to outdated_item_ids.

Suggested change
return [item_id for item_id in outdated_item_ids if item_id]
return outdated_item_ids

Comment on lines +485 to +491
icon = get_qt_icon(
{
"type": "material-symbols",
"name": status_item.icon,
"color": status_item.color,
}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
icon = get_qt_icon(
{
"type": "material-symbols",
"name": status_item.icon,
"color": status_item.color,
}
)
icon = get_qt_icon({
"type": "material-symbols",
"name": status_item.icon,
"color": status_item.color,
})

- Added support for version locking in container items.
- Included product group name and icon data for representation items.
- Updated item data handling to improve organization and display in the scene inventory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Issues and PRs coming from the community members size/M type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants