From 61e8ac95e621544b32ae324d7aec44b4e15bc81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 5 Oct 2019 18:09:48 +0800 Subject: Separate the product structure so the catalog doesn't have to included when not needed. --- catalog.cxx | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'catalog.cxx') diff --git a/catalog.cxx b/catalog.cxx index 03a90a1..ecc01a0 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -1,3 +1,6 @@ +#include +#include +#include #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 Catalog::roleNames() const { return QHash{ - {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(); } } -- cgit v1.2.3