VR-Engage  2.3
Loading...
Searching...
No Matches
vreStationListModel.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2026 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreStationListModel.h
7//! \ingroup vreManager
8//! \brief List model for VR-Engage station display
9//!
10//! This file defines the DtVreStationListModel class, which provides a
11//! Qt list model for displaying VR-Engage stations and their assignment status.
12//! The model consumes DtVreAssignmentTracker for assignment state.
13
14#pragma once
15
16#include "vreManager/export.h"
17
18#include <QAbstractListModel>
19#include <QIcon>
20
21#include <map>
22#include <string>
23#include <vector>
24
25#include <vrfutil/uuid.h>
26
27class QMimeData;
28
29
30namespace makVre
31{
32
34
35
36//! \brief Custom data roles for station list items
37//!
38//! These roles extend Qt's standard roles to provide station-specific
39//! data for delegates and other consumers.
41{
42 //! \brief QString: Station ID
43 StationIdRole = Qt::UserRole + 100,
44
45 //! \brief QString: Station name
47
48 //! \brief QString: Entity UUID (empty if unassigned)
50
51 //! \brief QString: Role name (empty if unassigned)
53
54 //! \brief QString: Entity display name (VR-Forces objectName, with DIS
55 //! marking text as a silent fallback)
57
58 //! \brief bool: True if station has any assignment
60
61 //! \brief bool: True if station has pending assignment
63
64 //! \brief bool: True if station's pending assignment has conflict
66
67 //! \brief bool: True if station is in spectator mode
69
70 //! \brief QString: Combined display text "EntityName / RoleName"
72
73 //! \brief int: Sort priority rank for status-based sorting.
74 //! Lower values appear first when sorting by status.
75 //! Order: 0=conflict, 1=pending assign, 2=pending unassign, 3=assigned, 4=unassigned
77
78 //! \brief bool: True if station is a synthetic offline placeholder.
80};
81
82
83//! \brief Assignment status for a station
84//!
85//! Represents the current assignment status of a station for display
86//! in the station list model.
88{
89 //! \brief No assignment (available for assignment)
91
92 //! \brief Has confirmed assignment from VRE
94
95 //! \brief Has pending assignment from Manager Panel
97
98 //! \brief Has pending assignment that conflicts with confirmed
100
101 //! \brief Has pending unassignment from Manager Panel
103};
104
105
106//! \brief List model for VR-Engage station display
107//!
108//! DtVreStationListModel provides a flat list model where each item
109//! represents a VR-Engage station. The model displays station names
110//! and their current assignment status (entity and role).
111//!
112//! The model consumes DtVreAssignmentTracker for assignment state and
113//! automatically refreshes when the tracker emits assignmentStateChanged().
114//!
115//! \par Custom Data Roles
116//! The model provides custom data roles (VreStationDataRole) for accessing
117//! station-specific information beyond standard Qt roles.
118//!
119//! \par Filtering
120//! The model supports filtering by station name through setFilterPattern().
121//! Use setShowOnlyUnassigned() to hide stations with current assignments.
122//!
123//! \par Drag and Drop
124//! The model supports drag operations for assigning stations to roles.
125//! Stations can be dragged to role nodes in the entity/role tree.
126//!
127//! \par Example Usage
128//! \code
129//! DtVreStationListModel* model = new DtVreStationListModel(tracker, this);
130//!
131//! QListView* view = new QListView(this);
132//! view->setModel(model);
133//! view->setDragEnabled(true);
134//! \endcode
135class VREMANAGER_DLL DtVreStationListModel : public QAbstractListModel
136{
137 Q_OBJECT
138
139public:
140 //! \brief Constructor
141 //! \param tracker Reference to the assignment tracker for state
142 //! \param parent Optional parent QObject for Qt memory management
143 DtVreStationListModel(DtVreAssignmentTracker& tracker, QObject* parent = nullptr);
144
145 //! \brief Destructor
146 virtual ~DtVreStationListModel() override;
147
148 // -------------------------------------------------------------------------
149 //! @name Query Methods
150 //! Methods for querying station information from model indices.
151 //! @{
152 // -------------------------------------------------------------------------
153
154 //! \brief Gets the station ID for a model index
155 //! \param index The model index
156 //! \return Station ID or empty string if invalid index
157 virtual std::string stationId(const QModelIndex& index) const;
158
159 //! \brief Gets the station name for a model index
160 //! \param index The model index
161 //! \return Station name or empty string if invalid index
162 virtual std::string stationName(const QModelIndex& index) const;
163
164 //! \brief Gets the assignment status for a station
165 //! \param index The model index
166 //! \return The station's current assignment status
167 virtual StationAssignmentStatus assignmentStatus(const QModelIndex& index) const;
168
169 //! \brief Gets the model index for a station ID
170 //! \param stationId The station ID to find
171 //! \return Model index for the station or invalid index if not found
172 virtual QModelIndex indexForStation(const std::string& stationId) const;
173
174 //! @}
175
176 // -------------------------------------------------------------------------
177 //! @name Filtering
178 //! Methods for filtering the displayed stations.
179 //! @{
180 // -------------------------------------------------------------------------
181
182 //! \brief Sets the filter pattern for station names
183 //! \param pattern Case-insensitive substring to filter by (empty shows all)
184 //!
185 //! Only stations whose name contains the pattern will be shown.
186 virtual void setFilterPattern(const std::string& pattern);
187
188 //! \brief Gets the current filter pattern
189 //! \return The current filter pattern
190 virtual std::string filterPattern() const;
191
192 //! \brief Sets whether to show only unassigned stations
193 //! \param showOnly If true, hide stations with assignments
194 virtual void setShowOnlyUnassigned(bool showOnly);
195
196 //! \brief Gets whether showing only unassigned stations
197 //! \return True if filtering to only show unassigned stations
198 virtual bool showOnlyUnassigned() const;
199
200 //! \brief Sets whether to show only assigned stations
201 //! \param showOnly If true, hide stations without any assignment
202 virtual void setShowOnlyAssigned(bool showOnly);
203
204 //! \brief Gets whether showing only assigned stations
205 //! \return True if filtering to only show assigned stations
206 virtual bool showOnlyAssigned() const;
207
208 //! \brief Sets whether to show only stations involved in conflicts
209 //! \param showOnly If true, only show stations with unresolved conflicts
210 virtual void setShowOnlyConflicts(bool showOnly);
211
212 //! \brief Gets whether showing only conflict stations
213 //! \return True if filtering to only show conflict stations
214 virtual bool showOnlyConflicts() const;
215
216 //! @}
217
218 // -------------------------------------------------------------------------
219 //! @name Entity Name Mapping
220 //! Methods for mapping entity UUIDs to display names.
221 //! @{
222 // -------------------------------------------------------------------------
223
224 //! \brief Sets the entity name for a UUID
225 //! \param entityUUID The entity UUID
226 //! \param displayName The display name (VR-Forces objectName, with DIS
227 //! marking text as a silent fallback)
228 //!
229 //! Used to display entity names in station assignment text.
230 //! Call this when entities are added to the exercise.
231 virtual void setEntityName(const DtUUID& entityUUID, const std::string& displayName);
232
233 //! \brief Removes the entity name mapping
234 //! \param entityUUID The entity UUID to remove
235 //!
236 //! Call this when entities are removed from the exercise.
237 virtual void removeEntityName(const DtUUID& entityUUID);
238
239 //! \brief Clears all entity name mappings
240 virtual void clearEntityNames();
241
242 //! \brief Gets the entity display name for a UUID.
243 //! \param entityUUID The entity UUID
244 //! \return Saved display name if known; otherwise a truncated UUID string.
245 virtual std::string entityDisplayName(const DtUUID& entityUUID) const;
246
247 //! \brief Gets the tracked object name for a UUID, or empty if unknown.
248 //! \param entityUUID The entity UUID
249 //! \return The tracked object name, or an empty string when none is tracked.
250 //!
251 //! Unlike entityDisplayName(), this never substitutes a truncated UUID, so it
252 //! is safe to persist: an entity whose name is not (yet) known is stored with
253 //! an empty object name — the UUID remains the identifier — rather than a
254 //! truncated-UUID string that would later be shown as if it were the name.
255 virtual std::string entityObjectName(const DtUUID& entityUUID) const;
256
257 //! \brief Builds the entity label shown for a station's assignment.
258 //! \param stationId The station ID
259 //! \param entityUUID The assigned entity UUID
260 //! \return The object name saved with an offline placeholder when available;
261 //! otherwise the resolved entity display name.
262 //!
263 //! Offline placeholders prefer their persisted object name so the card shows
264 //! a readable label even when the saved UUID does not reconstruct to a
265 //! resolvable DtUUID.
266 std::string assignmentEntityLabel(const std::string& stationId, const DtUUID& entityUUID) const;
267
268 //! \brief Stores the display icon for an entity UUID
269 //! \param entityUUID UUID of the entity
270 //! \param icon Icon to display when this entity is assigned to a station
271 //!
272 //! Called by DtVreManagerWidget whenever an entity is added to the tree.
273 //! A subsequent dataChanged emission is NOT required here — the icon will
274 //! be picked up on the next repaint triggered by assignment state changes.
275 //!
276 //! This single-icon overload is a thin shim that copies \p icon into both
277 //! the filled and outline cache slots; pending-state rows will therefore
278 //! show the same filled glyph. Prefer the two-icon overload below to get
279 //! distinct outline-only rendering for pending assignments (Phase 6).
280 virtual void setEntityIcon(const DtUUID& entityUUID, const QIcon& icon);
281
282 //! \brief Stores both the filled and outline-only display icons for an entity
283 //! \param entityUUID UUID of the entity
284 //! \param filledIcon Icon used for confirmed and conflicting assignments
285 //! \param outlineIcon Icon used for pending and pending-unassignment rows
286 //!
287 //! Phase 6: pending-assignment rows in the station list render the entity
288 //! symbol outline-only (no force-color fill) to distinguish them from
289 //! confirmed assignments. The two icons are produced once at ingestion by
290 //! DtVrfGuiSymbolMapper::getIcon(..., fillMilStdSymbol = true / false) and
291 //! cached together so paint never triggers a synchronous mapper call.
292 virtual void setEntityIcon(const DtUUID& entityUUID,
293 const QIcon& filledIcon,
294 const QIcon& outlineIcon);
295
296 //! \brief Removes the cached icon for an entity UUID
297 //! \param entityUUID UUID of the entity to remove
298 //!
299 //! Called by DtVreManagerWidget when an entity is removed from the tree.
300 virtual void clearEntityIcon(const DtUUID& entityUUID);
301
302 //! @}
303
304 // -------------------------------------------------------------------------
305 //! @name QAbstractListModel Interface
306 //! Standard Qt model interface implementation.
307 //! @{
308 // -------------------------------------------------------------------------
309
310 //! \brief Returns the number of rows in the model
311 //! \param parent Parent index (unused for list models)
312 //! \return Number of visible stations
313 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
314
315 //! \brief Returns data for the given index and role
316 //! \param index The model index
317 //! \param role The data role
318 //! \return Requested data as QVariant
319 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
320
321 //! \brief Returns item flags for the given index
322 //! \param index The model index
323 //! \return Item flags (e.g., selectable, draggable, drop-enabled)
324 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
325
326 //! \brief Returns supported drag actions
327 //! \return Supported drag actions (copy for assignment)
328 virtual Qt::DropActions supportedDragActions() const override;
329
330 //! \brief Returns MIME types for drag and drop
331 //! \return List of supported MIME types including station and role assignments
332 virtual QStringList mimeTypes() const override;
333
334 //! \brief Creates MIME data for drag
335 //! \param indexes Indexes to encode in MIME data
336 //! \return MIME data containing station ID
337 virtual QMimeData* mimeData(const QModelIndexList& indexes) const override;
338
339 //! \brief Returns supported drop actions
340 //! \return CopyAction for accepting role assignments
341 virtual Qt::DropActions supportedDropActions() const override;
342
343 //! \brief Checks whether dropped role data can be accepted
344 virtual bool canDropMimeData(const QMimeData* data, Qt::DropAction action,
345 int row, int column, const QModelIndex& parent) const override;
346
347 //! \brief Handles dropped role data to create a pending assignment
348 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action,
349 int row, int column, const QModelIndex& parent) override;
350
351 //! @}
352
353public slots:
354 //! \brief Refreshes the model from the tracker
355 //!
356 //! Called when the tracker's assignment state changes. Rebuilds
357 //! the station list and emits appropriate change signals.
358 virtual void refresh();
359
360signals:
361 //! \brief Emitted when a station is selected
362 //! \param stationId The selected station ID
363 void stationSelected(const std::string& stationId);
364
365protected:
366 //! \brief Reference to the assignment tracker
368
369 //! \brief Cached list of station IDs (for stable ordering)
370 std::vector<std::string> myStationIds;
371
372 //! \brief Map of entity UUID to display name
373 std::map<DtUUID, std::string> myEntityNames;
374
375 //! \brief Cached pair of entity icons keyed by UUID.
376 //!
377 //! Phase 6: stations whose assignment is pending render the entity symbol
378 //! outline-only to distinguish them from confirmed assignments. Both
379 //! variants are pre-computed at ingestion (see
380 //! DtVreManagerWidget::tryAddEntityToTree) and selected at paint time
381 //! based on the row's StationAssignmentStatus.
383 {
384 QIcon myFilled; //!< Force-color-filled MIL-STD symbol (Confirmed / PendingConflict)
385 QIcon myOutline; //!< Outline-only variant (Pending / PendingUnassignment)
386 };
387
388 //! \brief Map of entity UUID to its display icons (filled + outline)
389 //!
390 //! Populated by setEntityIcon() when entities are discovered and cleared by
391 //! clearEntityIcon() when entities are removed. Used in data() to return
392 //! entity-specific icons for the assignment indicator column.
393 std::map<DtUUID, EntityIcons> myEntityIconCache;
394
395 //! \brief Current filter pattern (lowercase)
396 std::string myFilterPattern;
397
398 //! \brief Whether to show only unassigned stations
400 bool myShowOnlyAssigned = false;
402
403 //! \brief Checks if a station passes the current filters
404 //! \param stationId Station ID to check
405 //! \return True if the station should be visible
406 virtual bool passesFilter(const std::string& stationId) const;
407
408 //! \brief Gets the visible station IDs
409 //! \return Vector of station IDs that pass filters
410 virtual std::vector<std::string> visibleStationIds() const;
411
412private:
413 //! \brief Copy constructor (deleted)
415
416 //! \brief Assignment operator (deleted)
418};
419
420} // namespace makVre
Centralized tracking of confirmed and pending station assignments.
Definition vreAssignmentTracker.h:187
virtual std::string entityDisplayName(const DtUUID &entityUUID) const
Gets the entity display name for a UUID.
virtual std::string stationName(const QModelIndex &index) const
Gets the station name for a model index.
DtVreStationListModel & operator=(const DtVreStationListModel &)=delete
Assignment operator (deleted)
virtual void setShowOnlyUnassigned(bool showOnly)
Sets whether to show only unassigned stations.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles dropped role data to create a pending assignment.
virtual QModelIndex indexForStation(const std::string &stationId) const
Gets the model index for a station ID.
bool myShowOnlyUnassigned
Whether to show only unassigned stations.
Definition vreStationListModel.h:399
bool myShowOnlyAssigned
Definition vreStationListModel.h:400
std::string assignmentEntityLabel(const std::string &stationId, const DtUUID &entityUUID) const
Builds the entity label shown for a station's assignment.
DtVreStationListModel(const DtVreStationListModel &)=delete
Copy constructor (deleted)
virtual Qt::DropActions supportedDragActions() const override
Returns supported drag actions.
virtual void removeEntityName(const DtUUID &entityUUID)
Removes the entity name mapping.
virtual std::vector< std::string > visibleStationIds() const
Gets the visible station IDs.
bool myShowOnlyConflicts
Definition vreStationListModel.h:401
virtual bool passesFilter(const std::string &stationId) const
Checks if a station passes the current filters.
DtVreStationListModel(DtVreAssignmentTracker &tracker, QObject *parent=nullptr)
Constructor.
virtual bool showOnlyUnassigned() const
Gets whether showing only unassigned stations.
virtual void clearEntityIcon(const DtUUID &entityUUID)
Removes the cached icon for an entity UUID.
virtual StationAssignmentStatus assignmentStatus(const QModelIndex &index) const
Gets the assignment status for a station.
std::map< DtUUID, std::string > myEntityNames
Map of entity UUID to display name.
Definition vreStationListModel.h:373
virtual void clearEntityNames()
Clears all entity name mappings.
virtual void setShowOnlyConflicts(bool showOnly)
Sets whether to show only stations involved in conflicts.
virtual bool showOnlyAssigned() const
Gets whether showing only assigned stations.
virtual std::string entityObjectName(const DtUUID &entityUUID) const
Gets the tracked object name for a UUID, or empty if unknown.
DtVreAssignmentTracker & myTracker
Reference to the assignment tracker.
Definition vreStationListModel.h:367
virtual void setEntityName(const DtUUID &entityUUID, const std::string &displayName)
Sets the entity name for a UUID.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
Creates MIME data for drag.
virtual ~DtVreStationListModel() override
Destructor.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
virtual std::string filterPattern() const
Gets the current filter pattern.
virtual void setShowOnlyAssigned(bool showOnly)
Sets whether to show only assigned stations.
virtual void setEntityIcon(const DtUUID &entityUUID, const QIcon &filledIcon, const QIcon &outlineIcon)
Stores both the filled and outline-only display icons for an entity.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows in the model.
std::vector< std::string > myStationIds
Cached list of station IDs (for stable ordering)
Definition vreStationListModel.h:370
virtual bool showOnlyConflicts() const
Gets whether showing only conflict stations.
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Checks whether dropped role data can be accepted.
std::map< DtUUID, EntityIcons > myEntityIconCache
Map of entity UUID to its display icons (filled + outline)
Definition vreStationListModel.h:393
void stationSelected(const std::string &stationId)
Emitted when a station is selected.
virtual Qt::DropActions supportedDropActions() const override
Returns supported drop actions.
virtual void setEntityIcon(const DtUUID &entityUUID, const QIcon &icon)
Stores the display icon for an entity UUID.
virtual void setFilterPattern(const std::string &pattern)
Sets the filter pattern for station names.
virtual std::string stationId(const QModelIndex &index) const
Gets the station ID for a model index.
virtual QStringList mimeTypes() const override
Returns MIME types for drag and drop.
virtual void refresh()
Refreshes the model from the tracker.
std::string myFilterPattern
Current filter pattern (lowercase)
Definition vreStationListModel.h:396
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Returns item flags for the given index.
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
@ Pending
Component still needs work — finalizeInitTick() will be called again.
Definition playerComponent.h:82
VreStationDataRole
Custom data roles for station list items.
Definition vreStationListModel.h:41
@ StationEntityNameRole
QString: Entity display name (VR-Forces objectName, with DIS marking text as a silent fallback)
Definition vreStationListModel.h:56
@ StationEntityUUIDRole
QString: Entity UUID (empty if unassigned)
Definition vreStationListModel.h:49
@ StationNameRole
QString: Station name.
Definition vreStationListModel.h:46
@ StationIsPendingRole
bool: True if station has pending assignment
Definition vreStationListModel.h:62
@ StationHasConflictRole
bool: True if station's pending assignment has conflict
Definition vreStationListModel.h:65
@ StationIsPlaceholderRole
bool: True if station is a synthetic offline placeholder.
Definition vreStationListModel.h:79
@ StationAssignmentTextRole
QString: Combined display text "EntityName / RoleName".
Definition vreStationListModel.h:71
@ StationIdRole
QString: Station ID.
Definition vreStationListModel.h:43
@ StationSortStatusRole
int: Sort priority rank for status-based sorting. Lower values appear first when sorting by status....
Definition vreStationListModel.h:76
@ StationRoleNameRole
QString: Role name (empty if unassigned)
Definition vreStationListModel.h:52
@ StationIsSpectatorRole
bool: True if station is in spectator mode
Definition vreStationListModel.h:68
@ StationIsAssignedRole
bool: True if station has any assignment
Definition vreStationListModel.h:59
StationAssignmentStatus
Assignment status for a station.
Definition vreStationListModel.h:88
@ Confirmed
Has confirmed assignment from VRE.
Definition vreStationListModel.h:93
@ Unassigned
No assignment (available for assignment)
Definition vreStationListModel.h:90
@ PendingUnassignment
Has pending unassignment from Manager Panel.
Definition vreStationListModel.h:102
@ PendingConflict
Has pending assignment that conflicts with confirmed.
Definition vreStationListModel.h:99
Cached pair of entity icons keyed by UUID.
Definition vreStationListModel.h:383
QIcon myOutline
Outline-only variant (Pending / PendingUnassignment)
Definition vreStationListModel.h:385
QIcon myFilled
Force-color-filled MIL-STD symbol (Confirmed / PendingConflict)
Definition vreStationListModel.h:384