VR-Engage  2.2
Loading...
Searching...
No Matches
vreTableModel.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreTableModel.h
7//! \ingroup vreManager
8//! \brief Table model for VREngage application status data
9//!
10//! This file defines the DtVreTableModel class, which provides a Qt table model
11//! for displaying and manipulating VREngage application status information.
12
13#pragma once
14
15#include "vreManager/export.h"
16
17#include <vlpi/simulationAddress.h>
18
19#include <QAbstractTableModel>
20#include <QStringList>
21
22namespace makVrv
23{
24class DtDe;
25}
26
27//! \brief Table model for VREngage application information
28//!
29//! This class implements a Qt table model for displaying and editing VREngage
30//! application information, including application names, assigned entities,
31//! station roles, and spectator mode settings.
32class VREMANAGER_DLL DtVreTableModel : public QAbstractTableModel
33{
34 Q_OBJECT
35public:
36 //! \brief Structure containing VREngage application status information
37 //!
38 //! Contains all the information about a VREngage application's identity and
39 //! current configuration settings displayed in the manager table.
40 using VreRecord = struct VreRecord
41 {
42 //! \brief Unique identifier for the VREngage application
43 unsigned long myId;
44
45 //! \brief Name of the VREngage application
46 std::string myName;
47
48 //! \brief UUID of the entity being controlled
49 std::string myEntityUUID;
50
51 //! \brief Marking text for the entity
52 std::string myMarkingText;
53
54 //! \brief Currently assigned station/role name
55 std::string myStationName;
56
57 //! \brief Flag indicating whether player is in spectator mode
58 bool mySpectator;
59
60 //! \brief Flag indicating whether the record has unsaved changes
61 bool myDirty;
62
63 //! \brief List of available station names for the entity
64 QStringList myStationNameList;
65 };
66
67 //! \brief Constructor
68 //! \param parent The parent QObject
69 //!
70 //! Initializes a new table model for VREngage application data.
71 DtVreTableModel(QObject* parent);
72
73 //! \brief Destructor
74 //!
75 //! Cleans up resources used by the table model.
76 virtual ~DtVreTableModel() override;
77 //! \brief Gets the number of rows in the model
78 //! \param parent The parent model index
79 //! \return The number of VREngage applications in the table
80 //!
81 //! Returns the number of rows (VREngage applications) in the table model.
82 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
83 //! \brief Gets the number of columns in the model
84 //! \param parent The parent model index
85 //! \return The number of data columns in the table
86 //!
87 //! Returns the number of columns (data fields) in the table model.
88 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
89 //! \brief Gets data for a cell in the table
90 //! \param index The model index of the cell
91 //! \param role The data role (display, edit, etc.)
92 //! \return The requested data as a QVariant
93 //!
94 //! Returns the data for the specified cell and role. Handles display formatting,
95 //! editor setup, and other data presentation aspects.
96 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
97 //! \brief Sets data for a cell in the table
98 //! \param index The model index of the cell to modify
99 //! \param value The new value to set
100 //! \param role The data role (usually Qt::EditRole)
101 //! \return True if successful, false otherwise
102 //!
103 //! Updates the data for the specified cell and marks the record as dirty to
104 //! indicate that changes need to be saved.
105 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
106 //! \brief Gets header data for the table
107 //! \param section The row or column number
108 //! \param orientation The header orientation (horizontal or vertical)
109 //! \param role The data role
110 //! \return The header data as a QVariant
111 //!
112 //! Returns header labels for the table columns.
113 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
114 //! \brief Gets flags for an item in the table
115 //! \param index The model index of the item
116 //! \return The item flags
117 //!
118 //! Returns the flags for the specified item, including whether it's editable,
119 //! selectable, enabled, etc.
120 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
121 //! \brief Adds a new VREngage application entry to the table
122 //! \param vreRecord The record to add
123 //!
124 //! Adds a new VREngage application record to the table model and notifies
125 //! views that the model has changed.
126 virtual void addEntry(const VreRecord& vreRecord);
127 //! \brief Removes a VREngage application entry from the table
128 //! \param id The unique identifier of the application to remove
129 //!
130 //! Removes the VREngage application with the specified ID from the table model
131 //! and notifies views that the model has changed.
132 virtual void removeEntry(unsigned long id);
133 //! \brief Updates an existing VREngage application entry
134 //! \param id The unique identifier of the application to update
135 //! \param vreRecord The new record data
136 //!
137 //! Updates the data for the VREngage application with the specified ID and
138 //! notifies views that the model has changed.
139 virtual void updateEntry(unsigned long id, const VreRecord& vreRecord);
140
141 //! \brief Gets the ID of a VREngage application by row
142 //! \param row The row index
143 //! \return The unique identifier of the application
144 //!
145 //! Returns the unique identifier of the VREngage application at the specified row.
146 //! TODO -- make these official columns and hide them
147 virtual unsigned long id(int row) const;
148 //! \brief Gets the entity UUID for a row
149 //! \param row The row index
150 //! \return The UUID of the entity assigned to the application
151 //!
152 //! Returns the UUID of the entity assigned to the VREngage application at the specified row.
153 virtual std::string entityUUID(int row) const;
154 //! \brief Checks if a row has unsaved changes
155 //! \param row The row index
156 //! \return True if the row has unsaved changes, false otherwise
157 //!
158 //! Returns whether the VREngage application record at the specified row has unsaved changes.
159 virtual bool isDirty(int row) const;
160 //! \brief Sets the dirty flag for a row
161 //! \param row The row index
162 //! \param flag The new dirty state
163 //!
164 //! Sets whether the VREngage application record at the specified row has unsaved changes.
165 virtual void setDirty(int row, bool flag);
166 //! \brief Checks if any rows in the table have unsaved changes
167 //! \return True if any row has unsaved changes, false otherwise
168 //!
169 //! Returns whether any VREngage application records in the table have unsaved changes.
170 virtual bool tableIsDirty() const;
171 //! \brief Clears all dirty flags in the table
172 //!
173 //! Marks all VREngage application records in the table as clean (no unsaved changes).
174 //! Called after changes have been saved or reverted.
175 virtual void clearDirtyFlags();
176
177 //! \brief Type definition for the table data container
178 //!
179 //! Vector of VREngage application records that makes up the table data.
180 using VreTable = std::vector<VreRecord>;
181
182protected:
183 //! \brief The table data
184 //!
185 //! Container for all VREngage application records in the table.
187};
virtual bool tableIsDirty() const
Checks if any rows in the table have unsaved changes.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Gets the number of columns in the model.
virtual unsigned long id(int row) const
Gets the ID of a VREngage application by row.
DtVreTableModel(QObject *parent)
Constructor.
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Gets flags for an item in the table.
virtual void updateEntry(unsigned long id, const VreRecord &vreRecord)
Updates an existing VREngage application entry.
std::vector< VreRecord > VreTable
Type definition for the table data container.
Definition vreTableModel.h:180
virtual ~DtVreTableModel() override
Destructor.
virtual bool isDirty(int row) const
Checks if a row has unsaved changes.
struct VreRecord { unsigned long myId; std::string myName; std::string myEntityUUID; std::string myMarkingText; std::string myStationName; bool mySpectator; bool myDirty; QStringList myStationNameList; } VreRecord
Structure containing VREngage application status information.
Definition vreTableModel.h:40
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Gets header data for the table.
virtual void addEntry(const VreRecord &vreRecord)
Adds a new VREngage application entry to the table.
virtual void setDirty(int row, bool flag)
Sets the dirty flag for a row.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets data for a cell in the table.
virtual std::string entityUUID(int row) const
Gets the entity UUID for a row.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Gets the number of rows in the model.
virtual void removeEntry(unsigned long id)
Removes a VREngage application entry from the table.
VreTable myData
The table data.
Definition vreTableModel.h:186
virtual void clearDirtyFlags()
Clears all dirty flags in the table.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Gets data for a cell in the table.
Export macros for the VREngage Manager library.
#define VREMANAGER_DLL
Platform-specific export/import macro for VREngage Manager library.
Definition export.h:28
Definition appLauncherComponent.h:28