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

Detailed Description

DtVreChatQML provides the bridge between the C++ chat functionality and the QML-based UI. It exposes properties and methods that can be accessed from QML to display chat messages, manage channels, and send/receive communications. This class handles the business logic of the chat system, including message formatting, channel management, and command processing.

#include <vreChatWindow.h>

Inheritance diagram for makVre::DtVreChatQML:
[legend]

Public Slots

void setCurrentUsername (QString username)
 
void setChat (DtVreChatModel *model)
 

Signals

void currentUsernameChanged (QString username)
 
void currentChannelIdxChanged (int channelIdx)
 
void chatChanged ()
 
void pinChatChanged (bool pinned)
 

Public Member Functions

 DtVreChatQML (DtPlayerStationApp &app, QObject *parent=nullptr)
 
virtual ~DtVreChatQML () override
 
virtual void sendToSystemChannel (const std::string &message)
 
virtual bool addChannel (const makVre::ChannelInfo &channelInfo, bool updateAvailableChannels=false)
 
virtual void updateAvailableChannels ()
 
virtual void clearChannels ()
 
virtual bool isChannelActive (const QString &channelName, int force)
 
virtual const std::vector< ChannelInfo > & getChannels () const
 
virtual void switchToFirstAvailableChannel ()
 
virtual void setUsingCustomUsername (bool usingCustom)
 
virtual bool isUsingCustomUsername () const
 
virtual QString entityMarkingText () const
 
virtual void setEntityMarkingText (QString val)
 
virtual int entityForce () const
 
virtual void setEntityForce (int val)
 
QString entityRole () const
 
void setEntityRole (QString val)
 
virtual void updateUsername ()
 
virtual void sendSlashCommand (const QString &message)
 
virtual void sendChatMessage (const QString &message, const QString &channel, const int force)
 
virtual bool sendChannelCommand (const QString &channelCommand)
 
virtual Q_INVOKABLE void send (const QString &message)
 
virtual Q_INVOKABLE void cycleChannels (bool direction)
 
virtual Q_INVOKABLE QVariant getChannelInfo (int idx)
 
virtual Q_INVOKABLE void togglePinChat ()
 
virtual QString getCurrentUsername ()
 
virtual DtVreChatModelgetChat ()
 

Static Public Member Functions

static std::string convertTextToHTML (const std::string &inputText)
 

Protected Attributes

QString myCurrentUsername
 
bool myUsingCustomUsername
 
QString myEntityMarkingText
 
QString myEntityRole
 
int myEntityForce
 
DtFilename myCurrentChatConfigFile
 
DtFilename myDefaultChatConfigFile
 
std::vector< ChannelInfomyChannels
 
int myCurrentChannelIdx
 
bool myPinChat
 
QScopedPointer< DtVreChatModelmyChatModel
 
DtPlayerStationAppmyApp
 

Properties

int currentChannelIdx
 
bool pinChat
 
QString currentUsername
 
DtVreChatModelchatModel
 

Constructor & Destructor Documentation

◆ DtVreChatQML()

makVre::DtVreChatQML::DtVreChatQML ( DtPlayerStationApp & app,
QObject * parent = nullptr )
explicit

Constructor.

Parameters
appReference to the player station application
parentParent QObject (default: nullptr)

Creates a new chat QML interface associated with the specified application. The interface will be initialized with default settings and an empty chat model.

◆ ~DtVreChatQML()

virtual makVre::DtVreChatQML::~DtVreChatQML ( )
overridevirtual

Virtual destructor.

Ensures proper cleanup of chat resources.

Member Function Documentation

◆ sendToSystemChannel()

virtual void makVre::DtVreChatQML::sendToSystemChannel ( const std::string & message)
virtual

Sends a message to the system channel.

Parameters
messageText message to send to the system channel

Sends a text message to the system notification channel, which is typically used for system events, errors, and information messages. These messages are visible to all users regardless of their channel settings.

◆ convertTextToHTML()

static std::string makVre::DtVreChatQML::convertTextToHTML ( const std::string & inputText)
static

Converts plain text to HTML format for QML display.

Parameters
inputTextPlain text to convert
Returns
HTML-formatted string

Converts a plain text string to HTML format, handling special characters, links, and other formatting needed for proper display in QML text components.

◆ addChannel()

virtual bool makVre::DtVreChatQML::addChannel ( const makVre::ChannelInfo & channelInfo,
bool updateAvailableChannels = false )
virtual

Adds a channel to the available channels list.

Parameters
channelInfoInformation about the channel to add
updateAvailableChannelsWhether to update the UI after adding the channel
Returns
True if channel was added successfully, false otherwise

Adds a new communication channel to the chat system. If a channel with the same name and force already exists, it will be updated instead.

References updateAvailableChannels().

◆ updateAvailableChannels()

virtual void makVre::DtVreChatQML::updateAvailableChannels ( )
virtual

Updates the list of available channels in the UI.

Refreshes the available channels list in the QML interface to reflect current channel state and availability.

Referenced by addChannel().

◆ clearChannels()

virtual void makVre::DtVreChatQML::clearChannels ( )
virtual

Removes all channels from the chat system.

Clears all channels from the chat system, typically used when disconnecting from a session or changing scenarios.

◆ isChannelActive()

virtual bool makVre::DtVreChatQML::isChannelActive ( const QString & channelName,
int force )
virtual

Checks if a channel is currently active.

Parameters
channelNameName of the channel to check
forceForce identifier of the channel
Returns
True if the channel is active, false otherwise

◆ getChannels()

virtual const std::vector< ChannelInfo > & makVre::DtVreChatQML::getChannels ( ) const
inlinevirtual

Gets the list of all available channels.

Returns
Constant reference to the vector of channel information

References myChannels.

◆ switchToFirstAvailableChannel()

virtual void makVre::DtVreChatQML::switchToFirstAvailableChannel ( )
virtual

Switches to the first available channel.

Selects the first available channel as the active channel. Used when initializing the chat or when the current channel becomes unavailable.

◆ setUsingCustomUsername()

virtual void makVre::DtVreChatQML::setUsingCustomUsername ( bool usingCustom)
inlinevirtual

Sets whether to use a custom username instead of entity name.

Parameters
usingCustomTrue to use custom username, false to use entity name

Controls whether the chat system uses a custom username specified by the user or automatically generates a username based on the entity information.

References myUsingCustomUsername.

◆ isUsingCustomUsername()

virtual bool makVre::DtVreChatQML::isUsingCustomUsername ( ) const
inlinevirtual

Checks if a custom username is being used.

Returns
True if using custom username, false if using auto-generated name

References myUsingCustomUsername.

◆ entityMarkingText()

virtual QString makVre::DtVreChatQML::entityMarkingText ( ) const
inlinevirtual

Gets the entity marking text for username generation.

Returns
Current entity marking (call sign) text

References myEntityMarkingText.

◆ setEntityMarkingText()

virtual void makVre::DtVreChatQML::setEntityMarkingText ( QString val)
inlinevirtual

Sets the entity marking text for username generation.

Parameters
valNew entity marking (call sign) text

References myEntityMarkingText.

◆ entityForce()

virtual int makVre::DtVreChatQML::entityForce ( ) const
inlinevirtual

Gets the entity force identifier for username generation.

Returns
Current entity force identifier

References myEntityForce.

◆ setEntityForce()

virtual void makVre::DtVreChatQML::setEntityForce ( int val)
inlinevirtual

Sets the entity force identifier for username generation.

Parameters
valNew entity force identifier

References myEntityForce.

◆ entityRole()

QString makVre::DtVreChatQML::entityRole ( ) const
inline

Gets the entity role text for username generation.

Returns
Current entity role description

References myEntityRole.

◆ setEntityRole()

void makVre::DtVreChatQML::setEntityRole ( QString val)
inline

Sets the entity role text for username generation.

Parameters
valNew entity role description

References myEntityRole.

◆ updateUsername()

virtual void makVre::DtVreChatQML::updateUsername ( )
virtual

Updates the username based on current settings.

Regenerates the username based on the current settings (custom or auto-generated). Auto-generated usernames typically combine entity marking, force, and role.

◆ sendSlashCommand()

virtual void makVre::DtVreChatQML::sendSlashCommand ( const QString & message)
virtual

Processes a slash command.

Parameters
messageCommand message starting with a slash (/)

Handles special commands that begin with a slash character, such as /help, /clear, /who, etc. This method is called from the send() method when a message begins with a slash.

◆ sendChatMessage()

virtual void makVre::DtVreChatQML::sendChatMessage ( const QString & message,
const QString & channel,
const int force )
virtual

Sends a regular chat message to a specific channel.

Parameters
messageText message to send
channelTarget channel name
forceForce identifier for the channel

Sends a chat message to the specified channel. This method is called from the send() method for regular (non-command) messages.

◆ sendChannelCommand()

virtual bool makVre::DtVreChatQML::sendChannelCommand ( const QString & channelCommand)
virtual

Processes a channel switching command.

Parameters
channelCommandCommand to switch channels (typically channel name)
Returns
True if channel switch was successful, false otherwise

Handles commands to switch between communication channels. This can be called directly or from a slash command like /channel [name].

◆ send()

virtual Q_INVOKABLE void makVre::DtVreChatQML::send ( const QString & message)
virtual

Processes and sends a message or command.

Parameters
messageText message or command to process

Main entry point for processing messages entered by the user. This method determines whether the message is a command (starts with slash) or a regular message, and routes it to the appropriate handler. This method is invokable from QML.

◆ cycleChannels()

virtual Q_INVOKABLE void makVre::DtVreChatQML::cycleChannels ( bool direction)
virtual

Cycles through available channels.

Parameters
directionTrue to cycle forward, false to cycle backward

Switches to the next or previous channel in the channel list based on the direction parameter. This method is invokable from QML.

◆ getChannelInfo()

virtual Q_INVOKABLE QVariant makVre::DtVreChatQML::getChannelInfo ( int idx)
virtual

Gets information about a specific channel.

Parameters
idxIndex of the channel to retrieve information for
Returns
QVariant containing the channel information

Retrieves detailed information about a channel at the specified index. The returned QVariant can be used in QML to display channel properties. This method is invokable from QML.

◆ togglePinChat()

virtual Q_INVOKABLE void makVre::DtVreChatQML::togglePinChat ( )
virtual

Toggles the pinned state of the chat window.

Switches between pinned (always visible) and unpinned (auto-hide) states for the chat window. This method is invokable from QML.

◆ getCurrentUsername()

virtual QString makVre::DtVreChatQML::getCurrentUsername ( )
virtual

Gets the current username.

Returns
Current username used in chat

◆ getChat()

virtual DtVreChatModel * makVre::DtVreChatQML::getChat ( )
virtual

Gets the chat message model.

Returns
Pointer to the current chat model

◆ setCurrentUsername

void makVre::DtVreChatQML::setCurrentUsername ( QString username)
slot

Sets the current username.

Parameters
usernameNew username to use in chat

◆ setChat

void makVre::DtVreChatQML::setChat ( DtVreChatModel * model)
slot

Sets the chat message model.

Parameters
modelNew chat model to use

◆ currentUsernameChanged

void makVre::DtVreChatQML::currentUsernameChanged ( QString username)
signal

Signal emitted when the username changes.

Parameters
usernameNew username

◆ currentChannelIdxChanged

void makVre::DtVreChatQML::currentChannelIdxChanged ( int channelIdx)
signal

Signal emitted when the active channel changes.

Parameters
channelIdxIndex of the new active channel

◆ chatChanged

void makVre::DtVreChatQML::chatChanged ( )
signal

Signal emitted when the chat model changes.

◆ pinChatChanged

void makVre::DtVreChatQML::pinChatChanged ( bool pinned)
signal

Signal emitted when the pinned state changes.

Parameters
pinnedNew pinned state

Member Data Documentation

◆ myCurrentUsername

QString makVre::DtVreChatQML::myCurrentUsername
protected

◆ myUsingCustomUsername

bool makVre::DtVreChatQML::myUsingCustomUsername
protected

◆ myEntityMarkingText

QString makVre::DtVreChatQML::myEntityMarkingText
protected

◆ myEntityRole

QString makVre::DtVreChatQML::myEntityRole
protected

Referenced by entityRole(), and setEntityRole().

◆ myEntityForce

int makVre::DtVreChatQML::myEntityForce
protected

Referenced by entityForce(), and setEntityForce().

◆ myCurrentChatConfigFile

DtFilename makVre::DtVreChatQML::myCurrentChatConfigFile
protected

◆ myDefaultChatConfigFile

DtFilename makVre::DtVreChatQML::myDefaultChatConfigFile
protected

◆ myChannels

std::vector<ChannelInfo> makVre::DtVreChatQML::myChannels
protected

Referenced by getChannels().

◆ myCurrentChannelIdx

int makVre::DtVreChatQML::myCurrentChannelIdx
protected

◆ myPinChat

bool makVre::DtVreChatQML::myPinChat
protected

◆ myChatModel

QScopedPointer<DtVreChatModel> makVre::DtVreChatQML::myChatModel
protected

◆ myApp

DtPlayerStationApp& makVre::DtVreChatQML::myApp
protected

Property Documentation

◆ currentChannelIdx

int makVre::DtVreChatQML::currentChannelIdx

Index of the currently active chat channel.

◆ pinChat

bool makVre::DtVreChatQML::pinChat

Flag indicating if the chat window is pinned (always visible)

◆ currentUsername

QString makVre::DtVreChatQML::currentUsername
readwrite

Current username for the chat system.

◆ chatModel

DtVreChatModel* makVre::DtVreChatQML::chatModel
readwrite

Model containing chat messages for display.


The documentation for this class was generated from the following file: