DtVreChatModel is a list model that maintains the collection of chat messages displayed in the chat UI. It extends QAbstractListModel to provide a Qt-compatible interface for the QML-based chat window, exposing properties of DtChatEntry objects as roles that can be bound to UI elements.
#include <vreChatWindowModel.h>
|
| | DtVreChatModel (QObject *parent=nullptr) |
| |
| virtual | ~DtVreChatModel () override=default |
| |
| virtual void | clear () |
| |
| virtual void | addChat (const DtChatEntry &entry) |
| |
| virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
| |
| virtual bool | removeRows (int row, int column=0, const QModelIndex &parent=QModelIndex()) override |
| |
| virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| |
| virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| |
| virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
| |
|
| virtual QHash< int, QByteArray > | roleNames () const override |
| |
◆ ChatRoles
Enumeration of data roles for accessing chat entry properties.
Defines the roles used to access specific properties of chat entries in the QML view. These roles are used in QML bindings to display the appropriate data for each chat message.
| Enumerator |
|---|
| UsernameRole | Role for accessing the sender's username.
|
| ChannelRole | Role for accessing the message channel.
|
| ForceRole | Role for accessing the sender's force identifier.
|
| MessageRole | Role for accessing the message content.
|
| OpacityRole | Role for accessing the message opacity.
|
| TimerStartedRole | Role for accessing the timer started flag.
|
| VisibleRole | Role for accessing the message visibility.
|
◆ DtVreChatModel()
| makVre::DtVreChatModel::DtVreChatModel |
( |
QObject * | parent = nullptr | ) |
|
Constructor.
- Parameters
-
| parent | Parent QObject (default: nullptr) |
Creates a new chat model with the specified parent object.
◆ ~DtVreChatModel()
| virtual makVre::DtVreChatModel::~DtVreChatModel |
( |
| ) |
|
|
overridevirtualdefault |
◆ clear()
| virtual void makVre::DtVreChatModel::clear |
( |
| ) |
|
|
virtual |
Clears all messages from the model.
Removes all chat entries from the model, effectively clearing the chat window display.
◆ addChat()
| virtual void makVre::DtVreChatModel::addChat |
( |
const DtChatEntry & | entry | ) |
|
|
virtual |
Adds a new chat message to the model.
- Parameters
-
Adds a new chat message to the model, which will then appear in the chat window UI.
◆ sort()
| virtual void makVre::DtVreChatModel::sort |
( |
int | column, |
|
|
Qt::SortOrder | order = Qt::AscendingOrder ) |
|
overridevirtual |
Sorts the model contents.
- Parameters
-
| column | Column to sort by |
| order | Sort order (ascending or descending) |
Required implementation from QAbstractListModel. Sorts the chat entries according to the specified criteria.
◆ removeRows()
| virtual bool makVre::DtVreChatModel::removeRows |
( |
int | row, |
|
|
int | column = 0, |
|
|
const QModelIndex & | parent = QModelIndex() ) |
|
overridevirtual |
Removes rows from the model.
- Parameters
-
| row | Starting row to remove |
| column | Column (unused in list models) |
| parent | Parent index (unused in list models) |
- Returns
- True if rows were successfully removed
Removes the specified chat entries from the model.
◆ rowCount()
| virtual int makVre::DtVreChatModel::rowCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
overridevirtual |
Gets the number of chat entries in the model.
- Parameters
-
| parent | Parent index (unused in list models) |
- Returns
- Number of chat entries
Returns the total number of chat messages in the model.
◆ data()
| virtual QVariant makVre::DtVreChatModel::data |
( |
const QModelIndex & | index, |
|
|
int | role = Qt::DisplayRole ) const |
|
overridevirtual |
Gets data for a specific role and index.
- Parameters
-
| index | Model index to get data for |
| role | Data role to retrieve |
- Returns
- QVariant containing the requested data
Retrieves specific property data from a chat entry based on the specified role. This is used by the QML view to display chat messages.
◆ setData()
| virtual bool makVre::DtVreChatModel::setData |
( |
const QModelIndex & | index, |
|
|
const QVariant & | value, |
|
|
int | role ) |
|
overridevirtual |
Sets data for a specific role and index.
- Parameters
-
| index | Model index to set data for |
| value | New value to set |
| role | Data role to set |
- Returns
- True if data was successfully set
Updates a specific property of a chat entry based on the specified role and value.
◆ roleNames()
| virtual QHash< int, QByteArray > makVre::DtVreChatModel::roleNames |
( |
| ) |
const |
|
overrideprotectedvirtual |
Maps role enum values to role name strings.
- Returns
- Hash mapping role IDs to role names
Provides the mapping between role enum values and their string names, which is required for QML access to the model data.
◆ myChat
List of chat entries in the model.
Contains all the chat messages currently displayed in the chat window.
The documentation for this class was generated from the following file: