GroupContextMenuHandler
GroupContextMenuHandler
Manages group-related context menu actions. More…
#include <GroupContextMenuHandler.hpp>
Inherits from QObject
Public Functions
| Name | |
|---|---|
| GroupContextMenuHandler(QObject * parent =[nullptr]) Construct a new GroupContextMenuHandler. |
|
| ~GroupContextMenuHandler() override | |
| void | setGroupManager(GroupManager * group_manager) Set the GroupManager to use for group operations. |
| void | setCallbacks(GroupContextMenuCallbacks const & callbacks) Set the callbacks for group operations. |
| void | setupGroupMenuSection(QMenu * menu, bool add_trailing_separator =false) Add group-related actions to a menu. |
| void | updateMenuState(QMenu * menu) Update the menu state based on current selection and available groups. |
| bool | hasGroupManager() const Check if the handler has a valid group manager. |
| bool | hasSelection() const Check if there is a current selection (uses callbacks). |
Detailed Description
Manages group-related context menu actions.
This class provides a reusable way to add group management functionality to context menus in different widgets. It handles:
- Creating “Create New Group” actions
- Dynamically populating “Assign to Group” submenus
- Providing “Ungroup Selected” functionality
- Managing action states based on selection and group manager availability
Usage:
- Create a GroupContextMenuHandler instance
- Set the GroupManager via setGroupManager()
- Set callbacks via setCallbacks()
- Call setupGroupMenuSection() to add group actions to your menu
- Call updateMenuState() before showing the context menu
Public Functions Documentation
function GroupContextMenuHandler
Construct a new GroupContextMenuHandler.
Parameters:
- parent Optional parent QObject
function ~GroupContextMenuHandler
function setGroupManager
Set the GroupManager to use for group operations.
Parameters:
- group_manager Pointer to the GroupManager (not owned)
function setCallbacks
Set the callbacks for group operations.
Parameters:
- callbacks Structure containing callback functions
function setupGroupMenuSection
Add group-related actions to a menu.
Parameters:
- menu The menu to add actions to
- add_trailing_separator If true, adds a separator after the group section
This adds:
- “Create New Group” action
- Separator
- “Ungroup Selected” action
- Separator (if add_trailing_separator is true)
- Dynamic “Assign to Group” submenu (populated via updateMenuState)
function updateMenuState
Update the menu state based on current selection and available groups.
Parameters:
- menu The menu to update (should be the same menu passed to setupGroupMenuSection)
This should be called before showing the context menu. It:
- Enables/disables actions based on whether there is a selection
- Shows/hides actions based on whether there is a group manager
- Populates the dynamic group assignment submenu with current groups
function hasGroupManager
Check if the handler has a valid group manager.
Return: True if a group manager is set
function hasSelection
Check if there is a current selection (uses callbacks).
Return: True if there are selected entities
Updated on 2026-11-13 at 20:25:40 +0000