diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-07 10:19:35 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-07 10:19:35 +0800 |
commit | a68fc492cf86a14cf9cf95d9f9a764cdf5b01007 (patch) | |
tree | 3f309d8be302266d4590862112549bc310cb79f0 /catalog.cxx | |
parent | d82340151ce274930f42701f5a9a0c4db702cba4 (diff) | |
parent | 9fef837e6275697f4562f60c2546c5e025ec5435 (diff) |
Merge branch 'master' into cmake
# Conflicts:
# qicclient.pro
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(); + } } } |