diff options
| author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-05 18:09:48 +0800 |
|---|---|---|
| committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-05 18:09:48 +0800 |
| commit | 61e8ac95e621544b32ae324d7aec44b4e15bc81d (patch) | |
| tree | f8526bf6e34f226c1bce1969a07b97903cffa258 /catalog.cxx | |
| parent | 5d36cbe8062af072958c37bb9c71b1e158074d3a (diff) | |
Separate the product structure
so the catalog doesn't have to included when not needed.
Diffstat (limited to 'catalog.cxx')
| -rw-r--r-- | catalog.cxx | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/catalog.cxx b/catalog.cxx index 03a90a1..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"} }; } @@ -54,7 +57,7 @@ namespace ICClient { if (catalog) { for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); - icclient_catalog_free(catalog); + icclient_freecatalog(catalog); emit updated(); } } |