|
VR-Engage
2.3
|
Paints each station item as a two-line card:
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>
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 |
| makVre::DtStationItemDelegate::DtStationItemDelegate | ( | QObject * | parent = nullptr | ) |
Constructor.
| parent | The parent object |
|
overridevirtual |
Destructor.
|
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.
| size | Pixmap and bounding-box edge length in pixels |
| color | Outline color for the circle |
|
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.
| rowRect | The full bounding rect of the row item |
| option | Style options for the item (reserved for future variant use) |
|
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.
| rowRect | The full bounding rect of the row item |
| option | Style options for the item (reserved for future variant use) |
|
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.
| painter | The painter to draw with |
| rect | Bounding rect for the indicator (see assignmentIndicatorRectInRow) |
| status | Assignment status of the station |
| entityIcon | Entity icon to draw (may be null for unassigned stations) |
| void makVre::DtStationItemDelegate::setSpectatorModeIcon | ( | const QIcon & | icon | ) |
Sets the icon used for the spectator mode toggle button (spectator active)
| icon | The icon to display when spectator mode is on |
| void makVre::DtStationItemDelegate::setSpectatorModeDisabledIcon | ( | const QIcon & | icon | ) |
Sets the icon used for the spectator mode toggle button (spectator inactive)
| icon | The icon to display when spectator mode is off |
|
overridevirtual |
Paints a station list item with two-line layout.
| painter | The painter to draw with |
| option | Style options for the item |
| index | The model index of the item |
|
overridevirtual |
Returns the preferred size for a station list item.
| option | Style options for the item |
| index | The model index of the item |
|
overridevirtual |
Handles mouse events for the embedded spectator mode toggle button.
| event | The incoming event |
| model | The item model |
| option | Style options for the item |
| index | The model index of the item |
|
signal |
Emitted when the spectator mode toggle button is clicked.
| stationId | The 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.
|
signal |
Emitted when the status indicator circle is clicked.
| stationId | The ID of the station to unassign or clear pending |
|
private |
Computes the bounding rect of the status indicator circle.
| option | Style options for the item |
|
private |
Computes the bounding rect of the spectator mode toggle button.
| option | Style options for the item |
| index | The model index of the item |
|
staticconstexpr |
Left padding inside each station card (pixels from item left edge)
|
staticconstexpr |
Width of the status icon drawn in each station card.
|
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.
|
private |
Icon shown when spectator mode is active.
|
private |
Icon shown when spectator mode is inactive.