12#include "vrvUtil/signalslib.h"
15#include <QAbstractListModel>
37 DtChatEntry(
const QString& sender,
const QString& receiver,
const double time,
const QString&
message);
138 virtual bool removeRows(
int row,
int column = 0,
const QModelIndex& parent = QModelIndex())
override;
144 virtual int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
153 virtual QVariant
data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
161 virtual bool setData(
const QModelIndex& index,
const QVariant& value,
int role)
override;
170 virtual QHash<int, QByteArray>
roleNames()
const override;
238 const QString& sender,
const QString& receiver,
const double time,
const QString& message);
Represents a single chat message entry.
Definition vreChatWindowModel.h:28
QString message() const
Gets the content of the message.
QString getReceiver() const
Gets the receiver's entity name.
void setSender(const QString &sender)
Sets the sender's entity name.
double getTime() const
Gets the simulation time of the message.
DtChatEntry()
Default constructor initializing empty chat entry.
QString mySender
Entity name of message sender.
Definition exampleQtQuick.h:64
void setTime(const double time)
Sets the simulation time of the message.
DtChatEntry(const QString &sender, const QString &receiver, const double time, const QString &message)
Constructor with all chat entry fields.
QString myMessage
Content of the chat message.
Definition vreChatWindowModel.h:109
QString getSender() const
Gets the sender's entity name.
QString getMessage() const
Gets the message text content.
void setMessage(const QString &message)
Sets the message text content.
double myTime
Simulation time of message.
Definition exampleQtQuick.h:66
void setReceiver(const QString &receiver)
Sets the receiver's entity name.
QString myReceiver
Entity name of message receiver.
Definition exampleQtQuick.h:65
Qt model for chat messages providing data to QML ListView.
Definition exampleQtQuick.h:82
DtChatQmlModel(QObject *parent=nullptr)
Constructor initializing the model.
virtual QHash< int, QByteArray > roleNames() const override
Maps role enum values to QML property names.
virtual QString getMessage(const int idx)
Gets the message text at a specific index.
virtual int getIndexOfName(const QString &messageName)
Finds the index of a message by its text content.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets data for a specific role at a given index.
virtual bool removeRows(int row, int column=0, const QModelIndex &parent=QModelIndex()) override
Removes rows from the model.
QList< DtChatEntry > myChatEntries
Storage for all chat entries.
Definition exampleQtQuick.h:172
ChatRoles
Custom roles for accessing chat entry fields from QML.
Definition exampleQtQuick.h:91
@ ReceiverRole
Access receiver name via "receiver" in QML.
Definition exampleQtQuick.h:93
@ MessageRole
Access message text via "msg" in QML.
Definition exampleQtQuick.h:95
@ SenderRole
Access sender name via "sender" in QML.
Definition exampleQtQuick.h:92
@ TimeRole
Access message time via "time" in QML.
Definition exampleQtQuick.h:94
virtual void clear()
Clears all chat entries from the model.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of entries in the model.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for a specific role at a given index.
virtual void addChatEntry(const DtChatEntry &entry)
Adds a new chat entry to the model.
virtual ~DtExampleChatWindow() override
Destructor for cleanup.
virtual void addNewMessage(const DtChatEntry &entry)
Adds a new message to the chat window.
DtExampleChatWindow()
Constructor that loads and initializes the QML chat window.
virtual Q_INVOKABLE void clearChat()
Clears all messages from the chat window.
std::string myTargetWindow
Target window name (empty for standalone)
Definition exampleQtQuick.h:243
virtual bool isVisible()
Checks if the chat window is currently visible.
virtual void addNewMessage(const QString &sender, const QString &receiver, const double time, const QString &message)
Adds a new message to the chat window.
virtual void open()
Opens the chat window (shows it).
QQuickItem * myRoot
Root QML item loaded from QML file.
Definition exampleQtQuick.h:241
virtual void close()
Closes the chat window (hides it).
std::string myTargetFile
QML file path relative to VR-Engage data directory.
Definition exampleQtQuick.h:244
virtual void initMain()
Initializes the QML root item after loading.
DtChatQmlModel myChatModel
Qt model exposed to QML for data binding.
Definition exampleQtQuick.h:242
virtual void setVisibility(bool visible)
Sets the visibility of the chat window.
Include export definitions for this library.
Definition glsVreMessageUtil.h:49