diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-06-15 18:08:35 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-06-15 18:08:35 +0800 |
commit | d0a8570fd5c46ad2cab21af0b8f5a299bcbc1792 (patch) | |
tree | a279d6903340ce0d3c7ab165a2fbd9ae7d73b5d8 | |
parent | ca179a4b0ed27a240bd3144a01e3c7ec13f75389 (diff) |
Product is back constructed using pointers
so that Item can easily subclass from Product later.
-rw-r--r-- | catalog.cxx | 2 | ||||
-rw-r--r-- | interchange/ord.hxx | 2 | ||||
-rw-r--r-- | interchange/product.hxx | 54 |
3 files changed, 29 insertions, 29 deletions
diff --git a/catalog.cxx b/catalog.cxx index aa1dd5f..3a9e901 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -7,7 +7,7 @@ namespace QInterchange { QAbstractListModel{parent} { for (size_t i = 0; i < catalog.length; i++) - addProduct(Product{catalog.products[i]}); + addProduct(Product{&catalog.products[i]}); } int Catalog::rowCount(QModelIndex const& parent) const diff --git a/interchange/ord.hxx b/interchange/ord.hxx index 7728085..34ff202 100644 --- a/interchange/ord.hxx +++ b/interchange/ord.hxx @@ -15,7 +15,7 @@ namespace QInterchange { NameRole }; Item(interchange_ord_item item) : - product{item.product}, + product{&item.product}, quantity{item.quantity}, name{item.name} {} Product product; diff --git a/interchange/product.hxx b/interchange/product.hxx index 8a46d89..d3246ed 100644 --- a/interchange/product.hxx +++ b/interchange/product.hxx @@ -25,37 +25,37 @@ namespace QInterchange { }; Product() {} - Product(struct interchange_product product) : - price{product.price}, - weight{product.weight} + Product(struct interchange_product *product) : + price{product->price}, + weight{product->weight} { - if (product.sku) - sku = QString{product.sku}; - if (product.description) - description = QString{product.description}; - if (product.title) - title = QString{product.title}; - if (product.comment) - comment = QString{product.comment}; - if (product.thumb) - thumb = QString{product.thumb}; - if (product.image) - image = QString{product.image}; - if (product.prod_group) - prodGroup = QString{product.prod_group}; - if (product.category) - category = QString{product.category}; - if (product.option_type) - optionType = QString{product.option_type}; - if (product.author) - author = QString{product.author}; - if (product.crosssell) { - auto crosssell = product.crosssell; + if (product->sku) + sku = QString{product->sku}; + if (product->description) + description = QString{product->description}; + if (product->title) + title = QString{product->title}; + if (product->comment) + comment = QString{product->comment}; + if (product->thumb) + thumb = QString{product->thumb}; + if (product->image) + image = QString{product->image}; + if (product->prod_group) + prodGroup = QString{product->prod_group}; + if (product->category) + category = QString{product->category}; + if (product->option_type) + optionType = QString{product->option_type}; + if (product->author) + author = QString{product->author}; + if (product->crosssell) { + auto crosssell = product->crosssell; for (size_t i = 0; i < crosssell->length; i++) crossSell << QString{crosssell->skus[i]}; } - if (product.image_large) - imageLarge = QString{product.image_large}; + if (product->image_large) + imageLarge = QString{product->image_large}; } QString sku; |