From 5f25bd6a8166258aa361b66d17cc7161d624a1ea 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: Fri, 4 Oct 2019 22:25:52 +0800 Subject: Catalog update frees the C version catalog --- catalog.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'catalog.cxx') diff --git a/catalog.cxx b/catalog.cxx index 8664cdc..709d20d 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -51,9 +51,11 @@ 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]}); + icclient_catalog_free(catalog); + } emit updated(); } -- cgit v1.2.3 From 5d36cbe8062af072958c37bb9c71b1e158074d3a 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 14:41:50 +0800 Subject: updated signal is emitted only when the catalog *is* updated --- catalog.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'catalog.cxx') diff --git a/catalog.cxx b/catalog.cxx index 709d20d..03a90a1 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -55,8 +55,8 @@ namespace ICClient { for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); icclient_catalog_free(catalog); + emit updated(); } - emit updated(); } } -- cgit v1.2.3 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