-
-
Notifications
You must be signed in to change notification settings - Fork 431
feat: Add hierarchical tag grouping with collapsible headers #1247
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: main
Are you sure you want to change the base?
Conversation
Groups thumbnails using collapsible groups based on tag selection. Thumbnails within the groups respect the user's other sorting choices. Features: - Hierarchical tag dropdown with grouping of parent/children tags in a table view so large amounts of tags can be handled (hopefully) - Collapsible/expandable groups with count badges in thumbnail view - The tags that act as headers respect the user's configuration and use the tags' configured colors - Auto-refreshes the thumbnail pane and group-by-tag dropdown on tag creation/modification no matter if it was through the tag manager or the right-hand pane - Works with all existing search/filter operations Core Library Changes: - Add `group_entries_by_tag()` method to generate a tag hierarchy - Add `get_grouping_tag_ids()` to fetch grouping tags - Extend `BrowsingState` with `group_by_tag_id` field - Add `GroupedSearchResult` dataclass with `TagGroup` hierarchy UI Components: - Added a new dropdown in main toolbar for tag selection to sort by. This works with parent tags so multiple tag groups are created in the thumbnail view. If an item has multiple sibling tags, it'll be put under a "Multiple Tags" grouping. - Implemented `GroupHeaderWidget` to create collapsible group headers - Extended `ThumbGridLayout` to render hierarchical grouped entries - Updated `update_browsing_state()` to handle grouped results Files Added: - src/tagstudio/qt/mixed/group_header.py - src/tagstudio/qt/mixed/group_by_tag_delegate.py Note: The QT components and the hierarchy generation were written with tool-assistance (Claude Code 4.5)
I got overzealous in updating the UI by starting to update the search element to handle a multi-columned layout. This isn't necessary for this feature, so I'm reverting it to main.
src/tagstudio/qt/ts_qt.py
Outdated
| block_signals: If True, block signals during population. | ||
| """ | ||
| if block_signals: | ||
| self.main_window.group_by_tag_combobox.blockSignals(True) |
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 is a QT thing so I would suggest adding the method to the ignore list for this rule.
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.
I added a quick check for Mock in the new code to prevent the math issues that occurred. I also went back and fixed up the linting issues caused by QT convention.
Added a check for Mock to the new code to handle tests to make sure they don't fail. Re-ran mypy and ruff. Fixes: - Added type check for view.columnWidth() to handle Mock objects in tests - Fixed test_title_update failures (There was a TypeError with Mock math) - Fixed test_add_tag_callback Qt event loop errors - Removed unused imports from group_by_tag_delegate.py (QRect, Qt) - Added type signatures for Qt method overrides (QModelIndex | QPersistentModelIndex) - Added linter suppressions for Qt API conventions (noqa: N802, FBT003) Changes: - src/tagstudio/qt/ts_qt.py: Added isinstance() check for Mock - src/tagstudio/qt/mixed/group_by_tag_delegate.py: Fixed imports and type signatures
Adds a feature to group thumbnails in the main window by a tag or by a parent tag.
Grouped thumbnails in each section respect the user's other sorting choices (filename/date created, sort direction, etc.)
Features:
Core Library Changes:
group_entries_by_tag()method to generate a tag hierarchyget_grouping_tag_ids()to fetch grouping tagsBrowsingStatewithgroup_by_tag_idfieldGroupedSearchResultdataclass withTagGrouphierarchyUI Components:
GroupHeaderWidgetto create collapsible group headersThumbGridLayoutto render hierarchical grouped entriesupdate_browsing_state()to handle grouped resultsFiles Added:
Notes:
black -l100, mypy, and ruff. I did my best to stick to the existing coding style.delete_tag()only containedpass. I implemented a fulldelete_tag()method to fix this so the sort-by-tag dropdown would be able to automatically update correctly.Summary
Adds a feature to group thumbnails in the main window by a single tag or by a parent tag.
Grouped thumbnails in each section respect the user's other sorting choices (filename/date created, sort direction, etc.)
Tasks Completed
Screenshots
New Toolbar Dropdown
Selecting a Parent Tag to Group By
Sorting complete
Example Item with Multiple Sibling Tags