-
Notifications
You must be signed in to change notification settings - Fork 67
Add enable grouping to scene inventory #1519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add enable grouping to scene inventory #1519
Conversation
- 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.
…ub.com/FuzzkingCool/ayon-core into add_enable_grouping_to_scene_inventory
| is_hero = False | ||
| status_name = None | ||
| else: | ||
| # Flat structure (original behavior) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| item_by_repre_id_by_project[project_name][representation_id] | |
| item_by_repre_id_by_project | |
| [project_name] | |
| [representation_id] |
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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] |
There was a problem hiding this comment.
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.
| return [item_id for item_id in outdated_item_ids if item_id] | |
| return outdated_item_ids |
| icon = get_qt_icon( | ||
| { | ||
| "type": "material-symbols", | ||
| "name": status_item.icon, | ||
| "color": status_item.color, | ||
| } | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
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
grouping_checkboxto the UI inwindow.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]_grouping_enabledstate, aset_enable_groupingmethod, and a_create_grouped_itemshelper to build the grouped item hierarchy. The model'srefreshmethod now supports both grouped and flat structures based on the grouping setting. [1] [2] [3]Additional info
Integration with View
set_enable_groupingto the view class to propagate the grouping state from the UI to the model.Refactoring and Bug Fixes
model.pyfor 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
get_outdated_item_idsto recursively traverse the model hierarchy, ensuring outdated items are correctly identified in both grouped and flat structures. [1] [2]Testing notes: