| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #ifndef CHATMODELS_H
- #define CHATMODELS_H
- #include <QDateTime>
- #include <QJsonArray>
- #include <QJsonObject>
- #include <QMetaType>
- #include <QString>
- #include <QVector>
- #include "widgets/chatView/chat1/chatmessage.h"
- // 聊天室信息模型
- class RoomInfo
- {
- Q_GADGET
- Q_PROPERTY(QString id MEMBER id)
- Q_PROPERTY(QString roomName MEMBER roomName)
- Q_PROPERTY(QString description MEMBER description)
- Q_PROPERTY(int maxUsers MEMBER maxUsers)
- Q_PROPERTY(QString creatorId MEMBER creatorId)
- Q_PROPERTY(QString createdAt MEMBER createdAt)
- public:
- RoomInfo() = default;
- QString id;
- QString roomName;
- QString description;
- int maxUsers = 100;
- QString creatorId;
- QString createdAt;
- };
- Q_DECLARE_METATYPE(RoomInfo)
- // // 聊天消息模型
- // class ChatMessageModel
- // {
- // Q_GADGET
- // Q_PROPERTY(qint64 messageId MEMBER messageId)
- // Q_PROPERTY(qint64 roomId MEMBER roomId)
- // Q_PROPERTY(qint64 senderId MEMBER senderId)
- // Q_PROPERTY(QString content MEMBER content)
- // Q_PROPERTY(QString type MEMBER type)
- // Q_PROPERTY(QString createdAt MEMBER createdAt)
- // public:
- // ChatMessageModel() = default;
- // qint64 messageId = 0;
- // qint64 roomId = 0;
- // qint64 senderId = 0;
- // QString content;
- // QString type;
- // QString createdAt;
- // // 转换为UI显示的ChatMessage
- // ChatMessage toChatMessage(bool isCurrentUser) const;
- // };
- // Q_DECLARE_METATYPE(ChatMessageModel)
- // 聊天室列表响应
- class RoomListData
- {
- Q_GADGET
- Q_PROPERTY(qint64 total MEMBER total)
- Q_PROPERTY(QJsonArray list MEMBER list)
- public:
- RoomListData() = default;
- qint64 total = 0;
- QJsonArray list;
- QVector<RoomInfo> getRooms() const;
- };
- Q_DECLARE_METATYPE(RoomListData)
- #endif // CHATMODELS_H
|