VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtStationItemDelegate Class Reference

Detailed Description

Paints each station item as a two-line card:

  • Line 1: status icon + station name (bold, larger font)
  • Line 2: assignment text such as "Entity / Role" (normal font)

For stations with any assignment (pending or confirmed) a spectator mode toggle button is drawn on the right-hand side of the card, vertically centred. For pending assignments the button is fully opaque and interactive; clicking it emits spectatorToggleClicked() to toggle spectator mode. For confirmed assignments the button is dimmed and acts as a read-only state indicator.

The delegate reads custom data roles from DtVreStationListModel to obtain the station name and assignment text separately so they can be rendered in different font sizes.

#include <stationItemDelegate.h>

Inheritance diagram for makVre::DtStationItemDelegate:
[legend]

Signals

void spectatorToggleClicked (QString stationId)
 
void statusIndicatorClicked (QString stationId)
 

Public Member Functions

 DtStationItemDelegate (QObject *parent=nullptr)
 
virtual ~DtStationItemDelegate () override
 
void setSpectatorModeIcon (const QIcon &icon)
 
void setSpectatorModeDisabledIcon (const QIcon &icon)
 
virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
virtual QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
virtual bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 

Static Public Member Functions

static QPixmap neutralStatusPixmap (int size, const QColor &color)
 
static QRect assignmentIndicatorRectInRow (const QRect &rowRect, const QStyleOptionViewItem &option)
 
static int nameLeftEdge (const QRect &rowRect, const QStyleOptionViewItem &option)
 
static void paintAssignmentIndicator (QPainter *painter, const QRect &rect, StationAssignmentStatus status, const QIcon &entityIcon)
 

Static Public Attributes

static constexpr int kCardHPadding = 10
 
static constexpr int kStatusIconSize = 16
 
static constexpr int kIconTextGap = 30
 

Private Member Functions

QRect statusIndicatorRect (const QStyleOptionViewItem &option) const
 
QRect spectatorButtonRect (const QStyleOptionViewItem &option, const QModelIndex &index) const
 

Private Attributes

QIcon mySpectatorModeIcon
 
QIcon mySpectatorModeDisabledIcon
 

Constructor & Destructor Documentation

◆ DtStationItemDelegate()

makVre::DtStationItemDelegate::DtStationItemDelegate ( QObject * parent = nullptr)

Constructor.

Parameters
parentThe parent object

◆ ~DtStationItemDelegate()

virtual makVre::DtStationItemDelegate::~DtStationItemDelegate ( )
overridevirtual

Destructor.

Member Function Documentation

◆ neutralStatusPixmap()

static QPixmap makVre::DtStationItemDelegate::neutralStatusPixmap ( int size,
const QColor & color )
static

Builds a neutral-state status-circle pixmap that geometrically matches the status circles painted on station cards.

The pixmap is sized size x size with the ellipse drawn inside the same inset (4 px) used by station cards, guaranteeing pixel-aligned horizontal centerlines when the icon is placed left-of-text in a button. The icon is outlined (not filled) using color so it reads as a "no-status" indicator on the sort header.

Parameters
sizePixmap and bounding-box edge length in pixels
colorOutline color for the circle
Returns
Transparent QPixmap containing the outline circle

◆ assignmentIndicatorRectInRow()

static QRect makVre::DtStationItemDelegate::assignmentIndicatorRectInRow ( const QRect & rowRect,
const QStyleOptionViewItem & option )
static

Returns the bounding rect of the assignment-indicator within a row.

This is the authoritative geometry for the status icon slot at the left of each station card. The sort-header button uses this to achieve pixel-perfect horizontal alignment with the card indicators underneath.

Parameters
rowRectThe full bounding rect of the row item
optionStyle options for the item (reserved for future variant use)
Returns
Rect of the assignment indicator in view coordinates

◆ nameLeftEdge()

static int makVre::DtStationItemDelegate::nameLeftEdge ( const QRect & rowRect,
const QStyleOptionViewItem & option )
static

Returns the x-coordinate of the left edge of the station-name text.

The station-name sort button uses this value so its label x-aligns with the card station-name baseline.

Parameters
rowRectThe full bounding rect of the row item
optionStyle options for the item (reserved for future variant use)
Returns
Left pixel x of the station name column

◆ paintAssignmentIndicator()

static void makVre::DtStationItemDelegate::paintAssignmentIndicator ( QPainter * painter,
const QRect & rect,
StationAssignmentStatus status,
const QIcon & entityIcon )
static

Paints the assignment-indicator icon at the given rect.

This is the authoritative painting function for the status icon slot. For unassigned stations it draws a grey dashed circle. For confirmed/pending stations it draws the entity icon. For conflict stations it adds a thin red border around the entity icon. For pending-unassignment stations it adds a thin orange border.

Parameters
painterThe painter to draw with
rectBounding rect for the indicator (see assignmentIndicatorRectInRow)
statusAssignment status of the station
entityIconEntity icon to draw (may be null for unassigned stations)

◆ setSpectatorModeIcon()

void makVre::DtStationItemDelegate::setSpectatorModeIcon ( const QIcon & icon)

Sets the icon used for the spectator mode toggle button (spectator active)

Parameters
iconThe icon to display when spectator mode is on

◆ setSpectatorModeDisabledIcon()

void makVre::DtStationItemDelegate::setSpectatorModeDisabledIcon ( const QIcon & icon)

Sets the icon used for the spectator mode toggle button (spectator inactive)

Parameters
iconThe icon to display when spectator mode is off

◆ paint()

virtual void makVre::DtStationItemDelegate::paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
overridevirtual

Paints a station list item with two-line layout.

Parameters
painterThe painter to draw with
optionStyle options for the item
indexThe model index of the item

◆ sizeHint()

virtual QSize makVre::DtStationItemDelegate::sizeHint ( const QStyleOptionViewItem & option,
const QModelIndex & index ) const
overridevirtual

Returns the preferred size for a station list item.

Parameters
optionStyle options for the item
indexThe model index of the item
Returns
Size hint accommodating two lines of text

◆ editorEvent()

virtual bool makVre::DtStationItemDelegate::editorEvent ( QEvent * event,
QAbstractItemModel * model,
const QStyleOptionViewItem & option,
const QModelIndex & index )
overridevirtual

Handles mouse events for the embedded spectator mode toggle button.

Parameters
eventThe incoming event
modelThe item model
optionStyle options for the item
indexThe model index of the item
Returns
True if the event was consumed by the spectator mode button

◆ spectatorToggleClicked

void makVre::DtStationItemDelegate::spectatorToggleClicked ( QString stationId)
signal

Emitted when the spectator mode toggle button is clicked.

Parameters
stationIdThe ID of the station whose spectator mode should be toggled

Connect this signal to a slot that calls DtVreAssignmentTracker::setPendingSpectatorMode() to toggle spectator mode. For confirmed (non-pending) stations the signal is still emitted but the connected slot will take no action — the button acts as a read-only indicator.

◆ statusIndicatorClicked

void makVre::DtStationItemDelegate::statusIndicatorClicked ( QString stationId)
signal

Emitted when the status indicator circle is clicked.

Parameters
stationIdThe ID of the station to unassign or clear pending

◆ statusIndicatorRect()

QRect makVre::DtStationItemDelegate::statusIndicatorRect ( const QStyleOptionViewItem & option) const
private

Computes the bounding rect of the status indicator circle.

Parameters
optionStyle options for the item
Returns
The status indicator rect in view coordinates

◆ spectatorButtonRect()

QRect makVre::DtStationItemDelegate::spectatorButtonRect ( const QStyleOptionViewItem & option,
const QModelIndex & index ) const
private

Computes the bounding rect of the spectator mode toggle button.

Parameters
optionStyle options for the item
indexThe model index of the item
Returns
The button rect in view coordinates, or an invalid QRect when the button is not shown (station is unassigned)

Member Data Documentation

◆ kCardHPadding

int makVre::DtStationItemDelegate::kCardHPadding = 10
staticconstexpr

Left padding inside each station card (pixels from item left edge)

◆ kStatusIconSize

int makVre::DtStationItemDelegate::kStatusIconSize = 16
staticconstexpr

Width of the status icon drawn in each station card.

◆ kIconTextGap

int makVre::DtStationItemDelegate::kIconTextGap = 30
staticconstexpr

Gap between status icon and station name text.

Sized to accommodate the sort-arrow indicator in the status column header (which sits in this gap when the status column is the active sort key) while leaving visible breathing room on either side of the arrow. Card rows use the same gap so the station name text in cards stays aligned with the "Station" header label.

◆ mySpectatorModeIcon

QIcon makVre::DtStationItemDelegate::mySpectatorModeIcon
private

Icon shown when spectator mode is active.

◆ mySpectatorModeDisabledIcon

QIcon makVre::DtStationItemDelegate::mySpectatorModeDisabledIcon
private

Icon shown when spectator mode is inactive.


The documentation for this class was generated from the following file: