VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVreChatModel Class Reference

Detailed Description

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>

Inheritance diagram for makVre::DtVreChatModel:
[legend]

Public Types

enum  ChatRoles {
  UsernameRole = Qt::UserRole + 1 , ChannelRole , ForceRole , MessageRole ,
  OpacityRole , TimerStartedRole , VisibleRole
}
 

Public Member Functions

 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
 

Protected Member Functions

virtual QHash< int, QByteArray > roleNames () const override
 

Protected Attributes

QList< DtChatEntrymyChat
 

Member Enumeration Documentation

◆ 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.

Constructor & Destructor Documentation

◆ DtVreChatModel()

makVre::DtVreChatModel::DtVreChatModel ( QObject * parent = nullptr)

Constructor.

Parameters
parentParent QObject (default: nullptr)

Creates a new chat model with the specified parent object.

◆ ~DtVreChatModel()

virtual makVre::DtVreChatModel::~DtVreChatModel ( )
overridevirtualdefault

Default destructor.

Member Function Documentation

◆ 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
entryChat entry to add

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
columnColumn to sort by
orderSort 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
rowStarting row to remove
columnColumn (unused in list models)
parentParent 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
parentParent 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
indexModel index to get data for
roleData 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
indexModel index to set data for
valueNew value to set
roleData 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.

Member Data Documentation

◆ myChat

QList<DtChatEntry> makVre::DtVreChatModel::myChat
protected

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: