smilesitemmodel.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "smilesitemmodel.h"
  2. SmilesItemModel::SmilesItemModel(const QString &_smilePicture,
  3. const QString &_smileText,
  4. QObject *parent) :
  5. ListItem(parent),
  6. m_picture(_smilePicture),
  7. m_text(_smileText)
  8. {
  9. }
  10. void SmilesItemModel::setPicture( const QString &_smilePicture )
  11. {
  12. if(m_picture != _smilePicture) {
  13. m_picture = _smilePicture;
  14. emit dataChanged();
  15. }
  16. }
  17. void SmilesItemModel::setText( const QString &_smileText)
  18. {
  19. if(m_text != _smileText) {
  20. m_text = _smileText;
  21. emit dataChanged();
  22. }
  23. }
  24. QHash<int, QByteArray> SmilesItemModel::roleNames() const
  25. {
  26. QHash<int, QByteArray> names;
  27. names[smPicture] = "smilePicture";
  28. names[smText] = "smileText";
  29. return names;
  30. }
  31. QVariant SmilesItemModel::data(int role) const
  32. {
  33. switch(role) {
  34. case smPicture:
  35. return picture();
  36. case smText:
  37. return text();
  38. default:
  39. return QVariant();
  40. }
  41. }
  42. void SmilesItemModel::copy( const SmilesItemModel *item )
  43. {
  44. m_picture = item->picture();
  45. m_text = item->text();
  46. }