diff options
Diffstat (limited to 'catalog.cxx')
-rw-r--r-- | catalog.cxx | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/catalog.cxx b/catalog.cxx index 8664cdc..ecc01a0 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -1,3 +1,6 @@ +#include <cstddef> +#include <icclient/catalog.h> +#include <icclient/client.h> #include "qicclient/catalog.hxx" namespace ICClient { @@ -16,16 +19,16 @@ namespace ICClient { auto product = products[row]; switch (role) { - case SkuRole: - return product.sku(); - case DescriptionRole: - return product.description(); - case CommentRole: - return product.comment(); - case ImageRole: - return product.image(); - case PriceRole: - return product.price(); + case Product::SkuRole: + return product.sku; + case Product::DescriptionRole: + return product.description; + case Product::CommentRole: + return product.comment; + case Product::ImageRole: + return product.image; + case Product::PriceRole: + return product.price; default: return QVariant(); } @@ -34,11 +37,11 @@ namespace ICClient { QHash<int, QByteArray> Catalog::roleNames() const { return QHash<int, QByteArray>{ - {SkuRole, "sku"} - , {DescriptionRole, "description"} - , {CommentRole, "comment"} - , {ImageRole, "image"} - , {PriceRole, "price"} + {Product::SkuRole, "sku"} + , {Product::DescriptionRole, "description"} + , {Product::CommentRole, "comment"} + , {Product::ImageRole, "image"} + , {Product::PriceRole, "price"} }; } @@ -51,10 +54,12 @@ namespace ICClient { void Catalog::update(icclient_catalog* catalog) { - if (catalog) + if (catalog) { for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); - emit updated(); + icclient_freecatalog(catalog); + emit updated(); + } } } |