msgitemmodel.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef MSGITEMMODEL_H
  2. #define MSGITEMMODEL_H
  3. #include "listmodel.h"
  4. #define MSGTYPE_TEXT 0
  5. #define MSGTYPE_ATTENTION 1
  6. class MsgItemModel : public ListItem
  7. {
  8. Q_OBJECT
  9. enum Roles {
  10. r_msgId = Qt::UserRole+1,
  11. r_msgResource,
  12. r_msgText,
  13. r_msgDateTime,
  14. r_msgDlr,
  15. r_msgMy,
  16. r_msgType
  17. };
  18. QString m_id; //bare jid
  19. QString m_resource;
  20. QString m_datetime;
  21. QString m_text;
  22. bool m_dlr;
  23. bool m_myMsg;
  24. int m_type;
  25. public:
  26. MsgItemModel(QObject *parent = 0): ListItem(parent) {}
  27. explicit MsgItemModel( const QString _msgId,
  28. const QString &_msgResource,
  29. const QString &_msgDateTime,
  30. const QString &_msgText,
  31. const bool &_msgDlr,
  32. const bool &_msgMy,
  33. const int &_msgType,
  34. QObject *parent = 0 );
  35. virtual QVariant data(int role) const;
  36. virtual QHash<int, QByteArray> roleNames() const;
  37. virtual QString id() const { return m_id; }
  38. void setMsgId( QString &_id );
  39. void setResource( QString &_resource );
  40. void setMsgText( QString &_msgText );
  41. void setMsgDateTime( QString &_msgDateTime );
  42. void setMsgDlr( bool _msgDlr );
  43. void setMsgMy( bool _msgMy );
  44. void setMsgType( int _msgType );
  45. inline QString msgId() const { return m_id; }
  46. inline QString msgResource() const { return m_resource; }
  47. inline QString msgText() const { return m_text; }
  48. inline QString msgDateTime() const { return m_datetime; }
  49. inline bool msgMy() const { return m_myMsg; }
  50. inline bool msgDlr() const { return m_dlr; }
  51. inline int msgType() const { return m_type; }
  52. signals:
  53. public slots:
  54. };
  55. #endif // MSGITEMMODEL_H