product.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #include "product.h"
  5. #include <QDebug>
  6. /*!
  7. \class Product
  8. \brief Represents a purchasable product.
  9. */
  10. /*!
  11. Constructor.
  12. */
  13. Product::Product(QObject *parent)
  14. : QObject(parent)
  15. {
  16. }
  17. /*!
  18. Destructor.
  19. */
  20. Product::~Product()
  21. {
  22. }
  23. // Property getters and setters
  24. QString Product::id() const
  25. {
  26. return m_productId;
  27. }
  28. void Product::setId(const QString s)
  29. {
  30. m_productId = s;
  31. }
  32. QString Product::thumbnail() const
  33. {
  34. return m_thumbnail;
  35. }
  36. void Product::setThumbnail(const QString s)
  37. {
  38. m_thumbnail = s;
  39. }
  40. QString Product::title() const
  41. {
  42. return m_title;
  43. }
  44. void Product::setTitle(const QString s)
  45. {
  46. m_title = s;
  47. }
  48. QString Product::price() const
  49. {
  50. return m_price;
  51. }
  52. void Product::setPrice(const QString s)
  53. {
  54. m_price = s;
  55. }
  56. QString Product::url() const
  57. {
  58. return m_url;
  59. }
  60. void Product::setUrl(const QString s)
  61. {
  62. m_url = s;
  63. }
  64. int Product::reqId() const
  65. {
  66. return m_reqId;
  67. }
  68. void Product::setReqId(const int i)
  69. {
  70. m_reqId = i;
  71. }
  72. /*!
  73. Sets the product data according to content of \a data.
  74. */
  75. void Product::setProductData(const IAPClient::ProductData data)
  76. {
  77. m_productId = data.productId;
  78. m_title = data.title;
  79. m_price = data.price;
  80. }
  81. /*!
  82. Sets the product data according to content of \a dataHash.
  83. */
  84. void Product::setProductData(const IAPClient::ProductDataHash dataHash)
  85. {
  86. m_productId = dataHash.value("id").toString();
  87. m_title = dataHash.value("shortdescription").toString();
  88. m_price = dataHash.value("price").toString();
  89. }
  90. /*!
  91. Returns true if this product matches \a data. False otherwise.
  92. */
  93. bool Product::equals(const Product *data)
  94. {
  95. if (m_productId == data->id() &&
  96. m_title == data->title() &&
  97. m_price == data->price() &&
  98. m_url == data->url() &&
  99. m_reqId == data->reqId())
  100. {
  101. // It's a match!
  102. return true;
  103. }
  104. return false;
  105. }