smthemeitemmodel.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "smthemeitemmodel.h"
  2. SmilesThemeItemModel::SmilesThemeItemModel(const QString &_themeSmName,
  3. const QString &_themeSmFile,
  4. const QString &_themeSmAuthor,
  5. const QString &_themeSmPicture,
  6. QObject *parent) :
  7. ListItem(parent),
  8. m_name(_themeSmName),
  9. m_file(_themeSmFile),
  10. m_author(_themeSmAuthor),
  11. m_picture(_themeSmPicture)
  12. {
  13. }
  14. void SmilesThemeItemModel::setName(const QString &_smileThemeName)
  15. {
  16. if(m_name != _smileThemeName) {
  17. m_name = _smileThemeName;
  18. emit dataChanged();
  19. }
  20. }
  21. void SmilesThemeItemModel::setFile(const QString &_smileThemeFile)
  22. {
  23. if(m_file != _smileThemeFile) {
  24. m_file = _smileThemeFile;
  25. emit dataChanged();
  26. }
  27. }
  28. void SmilesThemeItemModel::setAuthor(const QString &_smileThemeAuthor)
  29. {
  30. if(m_author != _smileThemeAuthor) {
  31. m_author = _smileThemeAuthor;
  32. emit dataChanged();
  33. }
  34. }
  35. void SmilesThemeItemModel::setPicture(const QString &_smileThemePicture)
  36. {
  37. if(m_picture != _smileThemePicture) {
  38. m_picture = _smileThemePicture;
  39. emit dataChanged();
  40. }
  41. }
  42. QHash<int, QByteArray> SmilesThemeItemModel::roleNames() const
  43. {
  44. QHash<int, QByteArray> names;
  45. names[smName] = "smileThemeName";
  46. names[smFile] = "smileThemeFile";
  47. names[smAuthor] = "smileThemeAuthor";
  48. names[smPicture] = "smileThemePicture";
  49. return names;
  50. }
  51. QVariant SmilesThemeItemModel::data(int role) const
  52. {
  53. switch(role) {
  54. case smName:
  55. return name();
  56. case smFile:
  57. return file();
  58. case smAuthor:
  59. return author();
  60. case smPicture:
  61. return picture();
  62. default:
  63. return QVariant();
  64. }
  65. }