VR-Engage  2.3
Loading...
Searching...
No Matches
entityRoleTreeDelegate.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2026 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file entityRoleTreeDelegate.h
7//! \ingroup vreManager
8//! \brief Custom delegate for column 1 of the entity/role tree
9//!
10//! This file defines the DtEntityRoleTreeDelegate class, which paints the
11//! assignment-status column (column 1) of the entity/role tree view.
12//! For role-leaf rows it renders an entity icon (or grey dashed outline circle
13//! when unassigned) plus station-name text by reusing
14//! DtStationItemDelegate::paintAssignmentIndicator. For branching rows
15//! (force / entity) it renders the "<assigned>/<total>" count text
16//! left-justified.
17
18#pragma once
19
20#include "vreManager/export.h"
22
23#include <QStyledItemDelegate>
24
25
26namespace makVre
27{
28
29
30//! \brief Custom delegate for column 1 of the entity/role tree
31//!
32//! Paints the assignment-status column for every node type:
33//! - **Role leaf nodes**: entity icon (assigned / pending / conflict) or grey
34//! dashed outline circle (unassigned), followed by the assigned station
35//! name(s). The icon is rendered via
36//! DtStationItemDelegate::paintAssignmentIndicator so conflict (red border)
37//! and pending-unassign (orange border) states are handled consistently.
38//! - **Entity / Force branching nodes**: left-justified "<assigned>/<total>"
39//! count text rendered in the standard item font.
40//!
41//! Install this delegate on column 1 only:
42//! \code
43//! view->setItemDelegateForColumn(1, new DtEntityRoleTreeDelegate(view));
44//! \endcode
45class VREMANAGER_DLL DtEntityRoleTreeDelegate : public QStyledItemDelegate
46{
47 Q_OBJECT
48
49public:
50 //! \brief Constructor
51 //! \param parent Optional parent QObject
52 explicit DtEntityRoleTreeDelegate(QObject* parent = nullptr);
53
54 //! \brief Destructor
55 virtual ~DtEntityRoleTreeDelegate() override;
56
57 //! \brief Paints a column-1 cell
58 //!
59 //! For role leaf rows: draws the assignment-indicator icon to the left,
60 //! then the station-name text. For branching rows: draws the count text
61 //! left-aligned using the standard item font and colour.
62 //!
63 //! \param painter The active painter
64 //! \param option Style options (rect, palette, state)
65 //! \param index The model index being painted (must be column 1)
66 virtual void paint(
67 QPainter* painter,
68 const QStyleOptionViewItem& option,
69 const QModelIndex& index) const override;
70
71 //! \brief Returns the preferred size hint for a column-1 cell
72 //! \param option Style options for the item
73 //! \param index The model index being sized
74 //! \return Preferred cell size
75 virtual QSize sizeHint(
76 const QStyleOptionViewItem& option,
77 const QModelIndex& index) const override;
78
79private:
80 //! \brief Derives the assignment status for a role node from its model data
81 //! \param index Model index of a role-leaf cell (column irrelevant)
82 //! \return StationAssignmentStatus for use with paintAssignmentIndicator
83 static StationAssignmentStatus assignmentStatusFromIndex(const QModelIndex& index);
84};
85
86
87} // namespace makVre
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the preferred size hint for a column-1 cell.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Paints a column-1 cell.
DtEntityRoleTreeDelegate(QObject *parent=nullptr)
Constructor.
virtual ~DtEntityRoleTreeDelegate() override
Destructor.
static StationAssignmentStatus assignmentStatusFromIndex(const QModelIndex &index)
Derives the assignment status for a role node from its model data.
Export macros for the VREngage Manager library.
#define VREMANAGER_DLL
Platform-specific export/import macro for VREngage Manager library.
Definition export.h:28
!
Definition glsVreMessageUtil.h:50
StationAssignmentStatus
Assignment status for a station.
Definition vreStationListModel.h:88
List model for VR-Engage station display.