Skip to main content

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

class GroupContextMenuHandler;

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:

  1. Create a GroupContextMenuHandler instance
  2. Set the GroupManager via setGroupManager()
  3. Set callbacks via setCallbacks()
  4. Call setupGroupMenuSection() to add group actions to your menu
  5. Call updateMenuState() before showing the context menu

Public Functions Documentation

function GroupContextMenuHandler

explicit GroupContextMenuHandler(
    QObject * parent =nullptr
)

Construct a new GroupContextMenuHandler.

Parameters:

  • parent Optional parent QObject

function ~GroupContextMenuHandler

~GroupContextMenuHandler() override

function setGroupManager

void setGroupManager(
    GroupManager * group_manager
)

Set the GroupManager to use for group operations.

Parameters:

function setCallbacks

void setCallbacks(
    GroupContextMenuCallbacks const & callbacks
)

Set the callbacks for group operations.

Parameters:

  • callbacks Structure containing callback functions

function setupGroupMenuSection

void setupGroupMenuSection(
    QMenu * menu,
    bool add_trailing_separator =false
)

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

void updateMenuState(
    QMenu * menu
)

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

bool hasGroupManager() const

Check if the handler has a valid group manager.

Return: True if a group manager is set

function hasSelection

bool hasSelection() const

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