rosteritemmodel.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef ROSTERITEMMODEL_H
  2. #define ROSTERITEMMODEL_H
  3. #include "listmodel.h"
  4. #define ROSTER_ITEM_CONTACT 0
  5. #define ROSTER_ITEM_MUC 1
  6. class RosterItemModel : public ListItem
  7. {
  8. Q_OBJECT
  9. public:
  10. enum Roles {
  11. cntGroup = Qt::UserRole+1,
  12. cntPicStatus,
  13. cntName,
  14. cntJid,
  15. cntResource,
  16. cntTextStatus,
  17. cntPicAvatar,
  18. cntUnreadMsg,
  19. cntItemType
  20. };
  21. public:
  22. RosterItemModel(QObject *parent = 0): ListItem(parent) {
  23. m_group = "";
  24. m_pic_status = "";
  25. m_name = "";
  26. m_jid = "";
  27. m_resource = "";
  28. m_text_status = "";
  29. m_avatar = "";
  30. m_unreadmsg = 0;
  31. m_item_type = 0;
  32. }
  33. explicit RosterItemModel( const QString &_contactGroup,
  34. const QString &_picStatus,
  35. const QString &_contactName,
  36. const QString &_contactJid,
  37. const QString &_contactResource,
  38. const QString &_contactTextStatus,
  39. const QString &_contactPicAvatar,
  40. const int _unreadMsg,
  41. const int _item_type = 0,
  42. QObject *parent = 0 );
  43. virtual QVariant data(int role) const;
  44. virtual QHash<int, QByteArray> roleNames() const;
  45. virtual QString id() const { return m_jid; }
  46. void setGroup( const QString &_contactGroup );
  47. void setPicStatus( const QString &_contactPicStatus );
  48. void setContactName( const QString &_contactName );
  49. void setJid( const QString &_contactJid );
  50. void setResource( const QString &_contactResource );
  51. void setTextStatus( const QString &_contactTextStatus );
  52. void setAvatar( const QString &_contactPicAvatar );
  53. void setUnreadMsg( const int _unreadMsg );
  54. void setItemType( const int _itemType );
  55. inline QString group() const { return m_group; }
  56. inline QString picStatus() const { return m_pic_status; }
  57. inline QString contactName() const { return m_name; }
  58. inline QString contactJid() const { return m_jid; }
  59. inline QString contactResource() const { return m_resource; }
  60. inline QString textStatus() const { return m_text_status; }
  61. inline QString picAvatar() const { return m_avatar; }
  62. inline int unreadMsg() const { return m_unreadmsg; }
  63. inline int itemType() const { return m_item_type; }
  64. void copy( const RosterItemModel* );
  65. private:
  66. QString m_group;
  67. QString m_pic_status;
  68. QString m_name;
  69. QString m_jid;
  70. QString m_resource;
  71. QString m_text_status;
  72. QString m_avatar;
  73. int m_unreadmsg;
  74. int m_item_type;
  75. };
  76. #endif // ROSTERITEMMODEL_H