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

Detailed Description

DtVreStationListModel provides a flat list model where each item represents a VR-Engage station. The model displays station names and their current assignment status (entity and role).

The model consumes DtVreAssignmentTracker for assignment state and automatically refreshes when the tracker emits assignmentStateChanged().

Custom Data Roles
The model provides custom data roles (VreStationDataRole) for accessing station-specific information beyond standard Qt roles.
Filtering
The model supports filtering by station name through setFilterPattern(). Use setShowOnlyUnassigned() to hide stations with current assignments.
Drag and Drop
The model supports drag operations for assigning stations to roles. Stations can be dragged to role nodes in the entity/role tree.
Example Usage
DtVreStationListModel* model = new DtVreStationListModel(tracker, this);
QListView* view = new QListView(this);
view->setModel(model);
view->setDragEnabled(true);
DtVreStationListModel(DtVreAssignmentTracker &tracker, QObject *parent=nullptr)
Constructor.

#include <vreStationListModel.h>

Inheritance diagram for makVre::DtVreStationListModel:
[legend]

Classes

struct  EntityIcons
 

Public Slots

virtual void refresh ()
 

Signals

void stationSelected (const std::string &stationId)
 

Public Member Functions

 DtVreStationListModel (DtVreAssignmentTracker &tracker, QObject *parent=nullptr)
 
virtual ~DtVreStationListModel () override
 
Query Methods

Methods for querying station information from model indices.

virtual std::string stationId (const QModelIndex &index) const
 
virtual std::string stationName (const QModelIndex &index) const
 
virtual StationAssignmentStatus assignmentStatus (const QModelIndex &index) const
 
virtual QModelIndex indexForStation (const std::string &stationId) const
 
Filtering

Methods for filtering the displayed stations.

virtual void setFilterPattern (const std::string &pattern)
 
virtual std::string filterPattern () const
 
virtual void setShowOnlyUnassigned (bool showOnly)
 
virtual bool showOnlyUnassigned () const
 
virtual void setShowOnlyAssigned (bool showOnly)
 
virtual bool showOnlyAssigned () const
 
virtual void setShowOnlyConflicts (bool showOnly)
 
virtual bool showOnlyConflicts () const
 
Entity Name Mapping

Methods for mapping entity UUIDs to display names.

virtual void setEntityName (const DtUUID &entityUUID, const std::string &displayName)
 
virtual void removeEntityName (const DtUUID &entityUUID)
 
virtual void clearEntityNames ()
 
virtual std::string entityDisplayName (const DtUUID &entityUUID) const
 
virtual std::string entityObjectName (const DtUUID &entityUUID) const
 
std::string assignmentEntityLabel (const std::string &stationId, const DtUUID &entityUUID) const
 
virtual void setEntityIcon (const DtUUID &entityUUID, const QIcon &icon)
 
virtual void setEntityIcon (const DtUUID &entityUUID, const QIcon &filledIcon, const QIcon &outlineIcon)
 
virtual void clearEntityIcon (const DtUUID &entityUUID)
 
QAbstractListModel Interface

Standard Qt model interface implementation.

virtual int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const override
 
virtual Qt::DropActions supportedDragActions () const override
 
virtual QStringList mimeTypes () const override
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const override
 
virtual Qt::DropActions supportedDropActions () const override
 
virtual bool canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 

Protected Member Functions

virtual bool passesFilter (const std::string &stationId) const
 
virtual std::vector< std::string > visibleStationIds () const
 

Protected Attributes

DtVreAssignmentTracker & myTracker
 
std::vector< std::string > myStationIds
 
std::map< DtUUID, std::string > myEntityNames
 
std::map< DtUUID, EntityIcons > myEntityIconCache
 
std::string myFilterPattern
 
bool myShowOnlyUnassigned = false
 
bool myShowOnlyAssigned = false
 
bool myShowOnlyConflicts = false
 

Private Member Functions

 DtVreStationListModel (const DtVreStationListModel &)=delete
 
DtVreStationListModel & operator= (const DtVreStationListModel &)=delete
 

Constructor & Destructor Documentation

◆ DtVreStationListModel() [1/2]

makVre::DtVreStationListModel::DtVreStationListModel ( DtVreAssignmentTracker & tracker,
QObject * parent = nullptr )

Constructor.

Parameters
trackerReference to the assignment tracker for state
parentOptional parent QObject for Qt memory management

Referenced by DtVreStationListModel(), and operator=().

◆ ~DtVreStationListModel()

virtual makVre::DtVreStationListModel::~DtVreStationListModel ( )
overridevirtual

Destructor.

◆ DtVreStationListModel() [2/2]

makVre::DtVreStationListModel::DtVreStationListModel ( const DtVreStationListModel & )
privatedelete

Copy constructor (deleted)

References DtVreStationListModel().

Member Function Documentation

◆ stationId()

virtual std::string makVre::DtVreStationListModel::stationId ( const QModelIndex & index) const
virtual

Gets the station ID for a model index.

Parameters
indexThe model index
Returns
Station ID or empty string if invalid index

Referenced by assignmentEntityLabel(), indexForStation(), passesFilter(), and stationSelected().

◆ stationName()

virtual std::string makVre::DtVreStationListModel::stationName ( const QModelIndex & index) const
virtual

Gets the station name for a model index.

Parameters
indexThe model index
Returns
Station name or empty string if invalid index

◆ assignmentStatus()

virtual StationAssignmentStatus makVre::DtVreStationListModel::assignmentStatus ( const QModelIndex & index) const
virtual

Gets the assignment status for a station.

Parameters
indexThe model index
Returns
The station's current assignment status

◆ indexForStation()

virtual QModelIndex makVre::DtVreStationListModel::indexForStation ( const std::string & stationId) const
virtual

Gets the model index for a station ID.

Parameters
stationIdThe station ID to find
Returns
Model index for the station or invalid index if not found

References stationId().

◆ setFilterPattern()

virtual void makVre::DtVreStationListModel::setFilterPattern ( const std::string & pattern)
virtual

Sets the filter pattern for station names.

Parameters
patternCase-insensitive substring to filter by (empty shows all)

Only stations whose name contains the pattern will be shown.

◆ filterPattern()

virtual std::string makVre::DtVreStationListModel::filterPattern ( ) const
virtual

Gets the current filter pattern.

Returns
The current filter pattern

◆ setShowOnlyUnassigned()

virtual void makVre::DtVreStationListModel::setShowOnlyUnassigned ( bool showOnly)
virtual

Sets whether to show only unassigned stations.

Parameters
showOnlyIf true, hide stations with assignments

◆ showOnlyUnassigned()

virtual bool makVre::DtVreStationListModel::showOnlyUnassigned ( ) const
virtual

Gets whether showing only unassigned stations.

Returns
True if filtering to only show unassigned stations

◆ setShowOnlyAssigned()

virtual void makVre::DtVreStationListModel::setShowOnlyAssigned ( bool showOnly)
virtual

Sets whether to show only assigned stations.

Parameters
showOnlyIf true, hide stations without any assignment

◆ showOnlyAssigned()

virtual bool makVre::DtVreStationListModel::showOnlyAssigned ( ) const
virtual

Gets whether showing only assigned stations.

Returns
True if filtering to only show assigned stations

◆ setShowOnlyConflicts()

virtual void makVre::DtVreStationListModel::setShowOnlyConflicts ( bool showOnly)
virtual

Sets whether to show only stations involved in conflicts.

Parameters
showOnlyIf true, only show stations with unresolved conflicts

◆ showOnlyConflicts()

virtual bool makVre::DtVreStationListModel::showOnlyConflicts ( ) const
virtual

Gets whether showing only conflict stations.

Returns
True if filtering to only show conflict stations

◆ setEntityName()

virtual void makVre::DtVreStationListModel::setEntityName ( const DtUUID & entityUUID,
const std::string & displayName )
virtual

Sets the entity name for a UUID.

Parameters
entityUUIDThe entity UUID
displayNameThe display name (VR-Forces objectName, with DIS marking text as a silent fallback)

Used to display entity names in station assignment text. Call this when entities are added to the exercise.

◆ removeEntityName()

virtual void makVre::DtVreStationListModel::removeEntityName ( const DtUUID & entityUUID)
virtual

Removes the entity name mapping.

Parameters
entityUUIDThe entity UUID to remove

Call this when entities are removed from the exercise.

◆ clearEntityNames()

virtual void makVre::DtVreStationListModel::clearEntityNames ( )
virtual

Clears all entity name mappings.

◆ entityDisplayName()

virtual std::string makVre::DtVreStationListModel::entityDisplayName ( const DtUUID & entityUUID) const
virtual

Gets the entity display name for a UUID.

Parameters
entityUUIDThe entity UUID
Returns
Saved display name if known; otherwise a truncated UUID string.

◆ entityObjectName()

virtual std::string makVre::DtVreStationListModel::entityObjectName ( const DtUUID & entityUUID) const
virtual

Gets the tracked object name for a UUID, or empty if unknown.

Parameters
entityUUIDThe entity UUID
Returns
The tracked object name, or an empty string when none is tracked.

Unlike entityDisplayName(), this never substitutes a truncated UUID, so it is safe to persist: an entity whose name is not (yet) known is stored with an empty object name — the UUID remains the identifier — rather than a truncated-UUID string that would later be shown as if it were the name.

◆ assignmentEntityLabel()

std::string makVre::DtVreStationListModel::assignmentEntityLabel ( const std::string & stationId,
const DtUUID & entityUUID ) const

Builds the entity label shown for a station's assignment.

Parameters
stationIdThe station ID
entityUUIDThe assigned entity UUID
Returns
The object name saved with an offline placeholder when available; otherwise the resolved entity display name.

Offline placeholders prefer their persisted object name so the card shows a readable label even when the saved UUID does not reconstruct to a resolvable DtUUID.

References stationId().

◆ setEntityIcon() [1/2]

virtual void makVre::DtVreStationListModel::setEntityIcon ( const DtUUID & entityUUID,
const QIcon & icon )
virtual

Stores the display icon for an entity UUID.

Parameters
entityUUIDUUID of the entity
iconIcon to display when this entity is assigned to a station

Called by DtVreManagerWidget whenever an entity is added to the tree. A subsequent dataChanged emission is NOT required here — the icon will be picked up on the next repaint triggered by assignment state changes.

This single-icon overload is a thin shim that copies icon into both the filled and outline cache slots; pending-state rows will therefore show the same filled glyph. Prefer the two-icon overload below to get distinct outline-only rendering for pending assignments (Phase 6).

◆ setEntityIcon() [2/2]

virtual void makVre::DtVreStationListModel::setEntityIcon ( const DtUUID & entityUUID,
const QIcon & filledIcon,
const QIcon & outlineIcon )
virtual

Stores both the filled and outline-only display icons for an entity.

Parameters
entityUUIDUUID of the entity
filledIconIcon used for confirmed and conflicting assignments
outlineIconIcon used for pending and pending-unassignment rows

Phase 6: pending-assignment rows in the station list render the entity symbol outline-only (no force-color fill) to distinguish them from confirmed assignments. The two icons are produced once at ingestion by DtVrfGuiSymbolMapper::getIcon(..., fillMilStdSymbol = true / false) and cached together so paint never triggers a synchronous mapper call.

◆ clearEntityIcon()

virtual void makVre::DtVreStationListModel::clearEntityIcon ( const DtUUID & entityUUID)
virtual

Removes the cached icon for an entity UUID.

Parameters
entityUUIDUUID of the entity to remove

Called by DtVreManagerWidget when an entity is removed from the tree.

◆ rowCount()

virtual int makVre::DtVreStationListModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
overridevirtual

Returns the number of rows in the model.

Parameters
parentParent index (unused for list models)
Returns
Number of visible stations

◆ data()

virtual QVariant makVre::DtVreStationListModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
overridevirtual

Returns data for the given index and role.

Parameters
indexThe model index
roleThe data role
Returns
Requested data as QVariant

Referenced by canDropMimeData(), and dropMimeData().

◆ flags()

virtual Qt::ItemFlags makVre::DtVreStationListModel::flags ( const QModelIndex & index) const
overridevirtual

Returns item flags for the given index.

Parameters
indexThe model index
Returns
Item flags (e.g., selectable, draggable, drop-enabled)

◆ supportedDragActions()

virtual Qt::DropActions makVre::DtVreStationListModel::supportedDragActions ( ) const
overridevirtual

Returns supported drag actions.

Returns
Supported drag actions (copy for assignment)

◆ mimeTypes()

virtual QStringList makVre::DtVreStationListModel::mimeTypes ( ) const
overridevirtual

Returns MIME types for drag and drop.

Returns
List of supported MIME types including station and role assignments

◆ mimeData()

virtual QMimeData * makVre::DtVreStationListModel::mimeData ( const QModelIndexList & indexes) const
overridevirtual

Creates MIME data for drag.

Parameters
indexesIndexes to encode in MIME data
Returns
MIME data containing station ID

◆ supportedDropActions()

virtual Qt::DropActions makVre::DtVreStationListModel::supportedDropActions ( ) const
overridevirtual

Returns supported drop actions.

Returns
CopyAction for accepting role assignments

◆ canDropMimeData()

virtual bool makVre::DtVreStationListModel::canDropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent ) const
overridevirtual

Checks whether dropped role data can be accepted.

References data().

◆ dropMimeData()

virtual bool makVre::DtVreStationListModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
overridevirtual

Handles dropped role data to create a pending assignment.

References data().

◆ refresh

virtual void makVre::DtVreStationListModel::refresh ( )
virtualslot

Refreshes the model from the tracker.

Called when the tracker's assignment state changes. Rebuilds the station list and emits appropriate change signals.

◆ stationSelected

void makVre::DtVreStationListModel::stationSelected ( const std::string & stationId)
signal

Emitted when a station is selected.

Parameters
stationIdThe selected station ID

References stationId().

◆ passesFilter()

virtual bool makVre::DtVreStationListModel::passesFilter ( const std::string & stationId) const
protectedvirtual

Checks if a station passes the current filters.

Parameters
stationIdStation ID to check
Returns
True if the station should be visible

References stationId().

◆ visibleStationIds()

virtual std::vector< std::string > makVre::DtVreStationListModel::visibleStationIds ( ) const
protectedvirtual

Gets the visible station IDs.

Returns
Vector of station IDs that pass filters

◆ operator=()

DtVreStationListModel & makVre::DtVreStationListModel::operator= ( const DtVreStationListModel & )
privatedelete

Assignment operator (deleted)

References DtVreStationListModel().

Member Data Documentation

◆ myTracker

DtVreAssignmentTracker& makVre::DtVreStationListModel::myTracker
protected

Reference to the assignment tracker.

◆ myStationIds

std::vector<std::string> makVre::DtVreStationListModel::myStationIds
protected

Cached list of station IDs (for stable ordering)

◆ myEntityNames

std::map<DtUUID, std::string> makVre::DtVreStationListModel::myEntityNames
protected

Map of entity UUID to display name.

◆ myEntityIconCache

std::map<DtUUID, EntityIcons> makVre::DtVreStationListModel::myEntityIconCache
protected

Map of entity UUID to its display icons (filled + outline)

Populated by setEntityIcon() when entities are discovered and cleared by clearEntityIcon() when entities are removed. Used in data() to return entity-specific icons for the assignment indicator column.

◆ myFilterPattern

std::string makVre::DtVreStationListModel::myFilterPattern
protected

Current filter pattern (lowercase)

◆ myShowOnlyUnassigned

bool makVre::DtVreStationListModel::myShowOnlyUnassigned = false
protected

Whether to show only unassigned stations.

◆ myShowOnlyAssigned

bool makVre::DtVreStationListModel::myShowOnlyAssigned = false
protected

◆ myShowOnlyConflicts

bool makVre::DtVreStationListModel::myShowOnlyConflicts = false
protected

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