chatmodels.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef CHATMODELS_H
  2. #define CHATMODELS_H
  3. #include <QDateTime>
  4. #include <QJsonArray>
  5. #include <QJsonObject>
  6. #include <QMetaType>
  7. #include <QString>
  8. #include <QVector>
  9. #include "widgets/chatView/chat1/chatmessage.h"
  10. // 聊天室信息模型
  11. class RoomInfo
  12. {
  13. Q_GADGET
  14. Q_PROPERTY(QString id MEMBER id)
  15. Q_PROPERTY(QString roomName MEMBER roomName)
  16. Q_PROPERTY(QString description MEMBER description)
  17. Q_PROPERTY(int maxUsers MEMBER maxUsers)
  18. Q_PROPERTY(QString creatorId MEMBER creatorId)
  19. Q_PROPERTY(QString createdAt MEMBER createdAt)
  20. public:
  21. RoomInfo() = default;
  22. QString id;
  23. QString roomName;
  24. QString description;
  25. int maxUsers = 100;
  26. QString creatorId;
  27. QString createdAt;
  28. };
  29. Q_DECLARE_METATYPE(RoomInfo)
  30. // // 聊天消息模型
  31. // class ChatMessageModel
  32. // {
  33. // Q_GADGET
  34. // Q_PROPERTY(qint64 messageId MEMBER messageId)
  35. // Q_PROPERTY(qint64 roomId MEMBER roomId)
  36. // Q_PROPERTY(qint64 senderId MEMBER senderId)
  37. // Q_PROPERTY(QString content MEMBER content)
  38. // Q_PROPERTY(QString type MEMBER type)
  39. // Q_PROPERTY(QString createdAt MEMBER createdAt)
  40. // public:
  41. // ChatMessageModel() = default;
  42. // qint64 messageId = 0;
  43. // qint64 roomId = 0;
  44. // qint64 senderId = 0;
  45. // QString content;
  46. // QString type;
  47. // QString createdAt;
  48. // // 转换为UI显示的ChatMessage
  49. // ChatMessage toChatMessage(bool isCurrentUser) const;
  50. // };
  51. // Q_DECLARE_METATYPE(ChatMessageModel)
  52. // 聊天室列表响应
  53. class RoomListData
  54. {
  55. Q_GADGET
  56. Q_PROPERTY(qint64 total MEMBER total)
  57. Q_PROPERTY(QJsonArray list MEMBER list)
  58. public:
  59. RoomListData() = default;
  60. qint64 total = 0;
  61. QJsonArray list;
  62. QVector<RoomInfo> getRooms() const;
  63. };
  64. Q_DECLARE_METATYPE(RoomListData)
  65. #endif // CHATMODELS_H