18#include <QAbstractItemModel>
21#include <vrfutil/uuid.h>
307 const std::vector<std::string>& availableRoles,
308 const QIcon& entityIcon = QIcon(),
int forceType = 0);
332 uint16_t siteId, uint16_t appId);
369 const std::vector<DtUUID>& chainUUIDs,
370 const std::vector<std::string>& chainNames,
371 const std::vector<QIcon>& chainIcons,
372 const std::vector<int>& chainForces);
386 const std::vector<DtUUID>& newChainUUIDs,
387 const std::vector<std::string>& newChainNames,
388 const std::vector<QIcon>& newChainIcons,
389 const std::vector<int>& newChainForces);
544 virtual QModelIndex
index(
int row,
int column,
const QModelIndex&
parent = QModelIndex())
const override;
549 virtual QModelIndex
parent(
const QModelIndex&
index)
const override;
565 virtual QVariant
data(
const QModelIndex&
index,
int role = Qt::DisplayRole)
const override;
570 virtual Qt::ItemFlags
flags(
const QModelIndex&
index)
const override;
577 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
594 virtual QMimeData*
mimeData(
const QModelIndexList& indexes)
const override;
604 int row,
int column,
const QModelIndex&
parent)
const override;
614 int row,
int column,
const QModelIndex&
parent)
override;
760 const std::vector<DtUUID>& chainUUIDs,
761 const std::vector<std::string>& chainNames,
762 const std::vector<QIcon>& chainIcons,
763 const std::vector<int>& chainForces);
Centralized tracking of confirmed and pending station assignments.
Definition vreAssignmentTracker.h:187
static void assertGuiThread()
Asserts (in debug builds) that we are on the GUI thread.
virtual QModelIndex parent(const QModelIndex &index) const override
Returns the parent index for a given index.
bool myShowOnlyAssigned
Whether to show only entities with assignments.
Definition vreEntityRoleTreeModel.h:668
EntityOrderMode entityOrderMode() const
Returns the mode passed to the last applyEntityOrder() call.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns.
virtual QModelIndex findFirstUnassignedRoleIndex(const QModelIndex &root) const
Depth-first finds the first unassigned role under a non-role index.
virtual void refresh()
Refreshes the model from the tracker.
virtual Qt::DropActions supportedDropActions() const override
Returns supported drop actions.
bool isAggregateEffectivelyAssigned(VreTreeNode *node) const
Checks if any descendant entity of an aggregate is effectively assigned.
void resortAllLevels()
Re-sorts every level of the tree in-place.
void roleSelected(const DtUUID &entityUUID, const std::string &roleName)
Emitted when a role is selected.
virtual void removeAggregateNodeIfEmpty(const DtUUID &aggregateUUID)
Removes an aggregate node if it has no remaining children (Phase 8)
virtual std::string filterPattern() const
Gets the current filter pattern.
virtual bool isAggregateNode(const QModelIndex &index) const
Checks if an index represents an aggregate node (Phase 8)
std::string myFilterPattern
Current filter pattern (lowercase)
Definition vreEntityRoleTreeModel.h:665
virtual QStringList mimeTypes() const override
Returns MIME types accepted for drop.
virtual bool isEntityNode(const QModelIndex &index) const
Checks if an index represents an entity node.
EntityOrderMode
Controls the primary sort key for applyEntityOrder()
Definition vreEntityRoleTreeModel.h:264
@ BySimEngine
Primary key = numeric (siteId, applicationId) pair on entity rows. Force buckets fall back to alphabe...
Definition vreEntityRoleTreeModel.h:275
@ ByName
Primary key = entity name (alpha); secondary = has-any-assignment.
Definition vreEntityRoleTreeModel.h:266
@ ByAssignment
Primary key = has-any-assignment; secondary = entity name (alpha).
Definition vreEntityRoleTreeModel.h:269
virtual ~DtVreEntityRoleTreeModel() override
Destructor.
Qt::SortOrder entityOrderDirection() const
Returns the direction passed to the last applyEntityOrder() call.
virtual bool isForceNode(const QModelIndex &index) const
Checks if an index represents a force node.
virtual VreTreeNode * getOrCreateAggregateChain(VreTreeNode *forceNode, const std::vector< DtUUID > &chainUUIDs, const std::vector< std::string > &chainNames, const std::vector< QIcon > &chainIcons, const std::vector< int > &chainForces)
Get-or-create the deepest aggregate node along a chain (Phase 8)
virtual bool showOnlyAssigned() const
Gets whether showing only assigned entities.
void entitySelected(const DtUUID &entityUUID)
Emitted when an entity is selected.
virtual bool passesFilter(VreTreeNode *node) const
Checks if an entity passes the current filters.
void branchDropCompleted(const DtUUID &entityUUID, const std::string &roleName)
Emitted after a branch drop resolves to a specific role.
virtual DtUUID aggregateUUID(const QModelIndex &index) const
Returns the aggregate UUID for a model index (Phase 8)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
void sortChildren(VreTreeNode *parent)
Sorts children of a parent node by assignment-first then alphabetical.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
virtual void removeEntity(const DtUUID &entityUUID)
Removes an entity from the tree.
DtVreEntityRoleTreeModel(DtVreAssignmentTracker &tracker, QObject *parent=nullptr)
Constructor.
void droppedOnRole(const QModelIndex &roleIndex)
Emitted after dropMimeData() resolves to a specific role node.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles dropped MIME data to create a pending assignment.
bool isRoleEffectivelyAssigned(VreTreeNode *node) const
Checks if a role has any effective assignment (confirmed or pending)
virtual VreTreeNode * nodeFromIndex(const QModelIndex &index) const
Gets the tree node for a model index.
virtual void removeForceNodeIfEmpty(int bucketKey)
Removes a force node if it has no entity children.
virtual int visibleRowCount(VreTreeNode *parent) const
Gets the visible row count for a parent.
std::map< DtUUID, VreTreeNode * > myEntityIndex
Map of entity UUID to entity node for fast lookup.
Definition vreEntityRoleTreeModel.h:659
virtual QModelIndex indexFromNode(VreTreeNode *node, int column=0) const
Creates a model index for a tree node.
virtual DtUUID entityUUID(const QModelIndex &index) const
Gets the entity UUID for a model index.
virtual void addEntity(const DtUUID &entityUUID, const std::string &displayName, const std::vector< std::string > &availableRoles, const QIcon &entityIcon=QIcon(), int forceType=0)
Adds an entity to the tree under the appropriate force group.
virtual void setEntitySimEngine(const DtUUID &entityUUID, uint16_t siteId, uint16_t appId)
Updates the cached Sim Engine (siteId, applicationId) for an entity.
bool myShowOnlyUnassigned
Whether to show only entities with no assignments.
Definition vreEntityRoleTreeModel.h:671
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Checks whether dropped data can be accepted.
virtual void setShowOnlyUnassigned(bool showOnly)
Sets whether to show only entities with no assignments.
DtVreEntityRoleTreeModel(const DtVreEntityRoleTreeModel &)=delete
Copy constructor (deleted)
bool isEntityEffectivelyAssigned(VreTreeNode *node) const
Checks if an entity has any effective assignment (confirmed or pending)
virtual VreTreeNode * visibleChild(VreTreeNode *parent, int visibleRow) const
Gets the nth visible child node.
std::map< int, VreTreeNode * > myForceIndex
Map of force type to force node for fast lookup.
Definition vreEntityRoleTreeModel.h:656
virtual bool showOnlyUnassigned() const
Gets whether showing only unassigned entities.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the given row, column, and parent.
virtual void setFilterPattern(const std::string &pattern)
Sets the filter pattern for entity names.
virtual void clearEntities()
Removes all entities from the tree.
EntityOrderMode myEntityOrderMode
Primary key for the last applyEntityOrder() call.
Definition vreEntityRoleTreeModel.h:677
virtual void moveEntityToForce(const DtUUID &entityUUID, int newRawForceType)
Moves an existing entity to a different force bucket.
virtual void removeAggregateNode(const DtUUID &aggregateUUID)
Removes an aggregate node from the tree (Phase 8)
virtual void onEntityAggregateChanged(const DtUUID &entityUUID, const std::vector< DtUUID > &newChainUUIDs, const std::vector< std::string > &newChainNames, const std::vector< QIcon > &newChainIcons, const std::vector< int > &newChainForces)
Reparent an entity row when its aggregate membership changes (Phase 8)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns header data for the given section.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
Creates MIME data for dragged role nodes.
virtual VreTreeNode * getOrCreateForceNode(int forceType)
Gets or creates the force group node for a given force type.
std::map< DtUUID, VreTreeNode * > myAggregateIndex
Map of aggregate UUID to aggregate node for fast lookup (Phase 8)
Definition vreEntityRoleTreeModel.h:662
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Returns item flags for the given index.
virtual bool isRoleNode(const QModelIndex &index) const
Checks if an index represents a role node.
virtual Qt::DropActions supportedDragActions() const override
Returns supported drag actions.
static std::string forceTypeLabel(int bucketKey)
Returns the display label for a force-bucket key.
virtual void setEntityAggregateChain(const DtUUID &entityUUID, const std::vector< DtUUID > &chainUUIDs, const std::vector< std::string > &chainNames, const std::vector< QIcon > &chainIcons, const std::vector< int > &chainForces)
Sets (or updates) the aggregate ancestry chain for an entity (Phase 8)
bool isForceEffectivelyAssigned(VreTreeNode *node) const
Checks if any entity within a force has any effective assignment.
Qt::SortOrder myEntityOrderDirection
Sort direction for the last applyEntityOrder() call.
Definition vreEntityRoleTreeModel.h:680
virtual void applyEntityOrder(EntityOrderMode mode, Qt::SortOrder direction)
Reorders the tree by mode and direction (one-shot)
static int forceBucketKey(int rawForceType)
Returns the bucket key used by myForceIndex for a raw force type.
std::vector< std::unique_ptr< VreTreeNode > > myRootNodes
Root nodes (force group nodes)
Definition vreEntityRoleTreeModel.h:653
DtVreAssignmentTracker & myTracker
Reference to the assignment tracker.
Definition vreEntityRoleTreeModel.h:650
virtual void setShowOnlyAssigned(bool showOnly)
Sets whether to show only entities with assignments.
virtual std::string roleName(const QModelIndex &index) const
Gets the role name for a model index.
DtVreEntityRoleTreeModel & operator=(const DtVreEntityRoleTreeModel &)=delete
Assignment operator (deleted)
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
ForceCategory
Standard SISO/VR-Link force category buckets.
Definition vreEntityRoleTreeModel.h:60
@ Friendly
Raw value 1 (DtForceFriendly)
Definition vreEntityRoleTreeModel.h:62
@ Opposing
Raw value 2 (DtForceOpposing)
Definition vreEntityRoleTreeModel.h:63
@ OtherRaw
Non-standard raw value (>3) — bucketed as "Other:N" per Len.
Definition vreEntityRoleTreeModel.h:65
@ Other
Raw value 0 (DtForceOther) — the canonical SISO "Other" bucket.
Definition vreEntityRoleTreeModel.h:61
@ Neutral
Raw value 3 (DtForceNeutral)
Definition vreEntityRoleTreeModel.h:64
VreTreeDataRole
Custom data roles for entity/role tree items.
Definition vreEntityRoleTreeModel.h:85
@ AssignedRoleCountRole
int: Number of roles with assignments on entity
Definition vreEntityRoleTreeModel.h:111
@ IsAggregateNodeRole
bool: True if this is an aggregate node (Phase 8)
Definition vreEntityRoleTreeModel.h:143
@ IsRoleNodeRole
bool: True if this is a role node (level 2)
Definition vreEntityRoleTreeModel.h:99
@ IsForceNodeRole
bool: True if this is a force node (level 0)
Definition vreEntityRoleTreeModel.h:93
@ AggregateUUIDRole
QString: Aggregate UUID (empty for non-aggregate rows)
Definition vreEntityRoleTreeModel.h:146
@ HasConflictRole
bool: True if pending assignment creates conflict
Definition vreEntityRoleTreeModel.h:108
@ IsSpectatorRole
bool: True if station is in spectator mode
Definition vreEntityRoleTreeModel.h:123
@ AssignedStationNamesRole
QString: Comma-separated station names assigned to role.
Definition vreEntityRoleTreeModel.h:120
@ TotalRoleCountRole
int: Total number of roles on entity
Definition vreEntityRoleTreeModel.h:114
@ IsAssignedRole
bool: True if role has confirmed or pending assignment
Definition vreEntityRoleTreeModel.h:102
@ RoleNameRole
QString: Role name (empty for entity and force nodes)
Definition vreEntityRoleTreeModel.h:90
@ AssignmentBadgeTextRole
QString: Badge text like "(2/3)" for entity nodes.
Definition vreEntityRoleTreeModel.h:117
@ IsPendingRole
bool: True if has pending assignment
Definition vreEntityRoleTreeModel.h:105
@ SimEngineSortKeyRole
uint: Numeric composite key (siteId<<16 | applicationId) for the Sim Engine column (column 2) on enti...
Definition vreEntityRoleTreeModel.h:140
@ EntityUUIDRole
QString: Entity UUID.
Definition vreEntityRoleTreeModel.h:87
@ IsEntityNodeRole
bool: True if this is an entity node (level 1)
Definition vreEntityRoleTreeModel.h:96
@ AssignedStationPartsRole
QVariantList: Per-station parts for rich rendering. Each entry is a QVariantMap with keys: "name" -> ...
Definition vreEntityRoleTreeModel.h:130
VREMANAGER_DLL ForceCategory forceCategoryFromRaw(int rawForceType)
Maps a raw SISO force-type value to a ForceCategory.
VreNodeType
Node type for the (possibly four-level+) hierarchy.
Definition vreEntityRoleTreeModel.h:43
@ AggregateNode
Optional intermediate aggregate node (may nest)
Definition vreEntityRoleTreeModel.h:45
@ RoleNode
Leaf-level role node.
Definition vreEntityRoleTreeModel.h:47
@ EntityNode
Entity row (parent may be a ForceNode or an AggregateNode)
Definition vreEntityRoleTreeModel.h:46
@ ForceNode
Top-level force grouping node (friendly, opposing, etc.)
Definition vreEntityRoleTreeModel.h:44
Internal tree node for force/entity/role hierarchy.
Definition vreEntityRoleTreeModel.h:155
int myCachedAssignedCount
Cached assigned-role count for this node (-1 = invalid / not yet cached)
Definition vreEntityRoleTreeModel.h:193
bool mySimEngineKnown
True if the cached (site, app) pair has been populated for this entity.
Definition vreEntityRoleTreeModel.h:214
VreTreeNode * myParent
Parent node (nullptr for root force nodes)
Definition vreEntityRoleTreeModel.h:178
uint16_t mySimEngineSite
Cached SISO siteId for the Sim Engine column (entity nodes only)
Definition vreEntityRoleTreeModel.h:203
uint16_t mySimEngineApp
Cached SISO applicationId / host for the Sim Engine column (entity nodes only)
Definition vreEntityRoleTreeModel.h:206
DtUUID myEntityUUID
Entity UUID (for entity and role nodes; null UUID for force nodes)
Definition vreEntityRoleTreeModel.h:160
int myCachedTotalCount
Cached total-role count for this node (-1 = invalid / not yet cached)
Definition vreEntityRoleTreeModel.h:200
std::string mySimEngineCached
Pre-formatted "site:app" string for Qt::DisplayRole on column 2.
Definition vreEntityRoleTreeModel.h:220
std::string myDisplayName
Display name (force label, entity objectName / marking-text fallback, or role name)
Definition vreEntityRoleTreeModel.h:169
VreNodeType myNodeType
Node type in the hierarchy.
Definition vreEntityRoleTreeModel.h:157
std::vector< std::unique_ptr< VreTreeNode > > myChildren
Child nodes (entity nodes for force nodes, role nodes for entity nodes)
Definition vreEntityRoleTreeModel.h:181
std::vector< std::string > myAvailableRoles
Available roles for this entity (entity nodes only)
Definition vreEntityRoleTreeModel.h:175
int myRow
Index of this node within parent's children.
Definition vreEntityRoleTreeModel.h:184
int myForceType
Force type value (force nodes only; SISO force ID)
Definition vreEntityRoleTreeModel.h:172
QIcon myEntityIcon
Entity type icon (entity nodes only; null for force and role nodes)
Definition vreEntityRoleTreeModel.h:187
std::string myRoleName
Role name (empty for entity and force nodes)
Definition vreEntityRoleTreeModel.h:166
DtUUID myAggregateUUID
Aggregate UUID (Phase 8 — valid only for AggregateNode rows)
Definition vreEntityRoleTreeModel.h:163