From f8e6bbd50bd5f8f866e3786efa41d497b1e71d3d 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: Mon, 29 Jun 2020 17:28:29 +0800 Subject: Bring back basket update member function --- basket.cxx | 10 ++++++++-- client.cxx | 4 ++-- qicclient/basket.hxx | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/basket.cxx b/basket.cxx index 7b3336a..b730bf6 100644 --- a/basket.cxx +++ b/basket.cxx @@ -59,11 +59,17 @@ namespace ICClient { items << item; endInsertRows(); emit rowCountChanged(); + } - /* + void Basket::update(icclient_ord_order* order) + { + if (order) + for (size_t i = 0; i < order->nitems; i++) + addItem(Item{order->items[i]}); m_subtotal = order->subtotal; + emit subtotalChanged(); m_totalCost = order->total_cost; - */ + emit totalCostChanged(); } } diff --git a/client.cxx b/client.cxx index 5ca3ce6..0d3316d 100644 --- a/client.cxx +++ b/client.cxx @@ -47,8 +47,8 @@ namespace ICClient { void Client::order(QString const& sku, Catalog const& catalog, Basket& order) { auto c_order = order.c_order(); - icclient_order(sku.toLatin1().constData(), catalog.c_catalog(), - &c_order); + icclient_order(sku.toLatin1().constData(), catalog.c_catalog(), &c_order); + order.update(c_order); } void Client::logIn(size_t (*handler)(void*, size_t, size_t, void*) diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx index f5665cd..8d697e6 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -55,6 +55,7 @@ namespace ICClient { double shipping() const { return m_shipping; } double totalCost() const { return m_totalCost; } icclient_ord_order* c_order() { return order; } + void update(icclient_ord_order* order); signals: void rowCountChanged(); -- cgit v1.2.3