diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2020-06-30 17:26:38 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2020-06-30 17:26:38 +0800 |
commit | 30da849074d90ecd7baaf7705aee81149c732dcd (patch) | |
tree | 347dd3f6c6834db69abde4e64f3eea8e6495abd1 | |
parent | dd94e52d98aa29e0273176e038864c13fbd4aa6b (diff) |
Getter setter for C struct data
-rw-r--r-- | basket.cxx | 2 | ||||
-rw-r--r-- | client.cxx | 4 | ||||
-rw-r--r-- | qicclient/basket.hxx | 20 |
3 files changed, 13 insertions, 13 deletions
@@ -61,7 +61,7 @@ namespace ICClient { emit rowCountChanged(); } - void Basket::update(icclient_ord_order* order) + void Basket::setData(icclient_ord_order* order) { if (order) for (size_t i = 0; i < order->nitems; i++) @@ -44,9 +44,9 @@ namespace ICClient { void Client::order(QString const& sku, Catalog const& catalog, Basket& order) { - auto c_order = order.c_order(); + auto c_order = order.data(); icclient_order(sku.toLatin1().constData(), catalog.c_catalog(), &c_order); - order.update(c_order); + order.setData(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 8d697e6..af4d81c 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -38,24 +38,24 @@ namespace ICClient { Q_PROPERTY(double totalCost READ totalCost NOTIFY totalCostChanged) public: - explicit Basket(QObject* parent = nullptr) - : QAbstractListModel{parent} - , m_subtotal{.0} - , m_shipping{.0} - , m_totalCost{.0} + explicit Basket(QObject* parent = nullptr) : + QAbstractListModel{parent}, + m_subtotal{.0}, + m_shipping{.0}, + m_totalCost{.0} {} + int rowCount(QModelIndex const& parent + = QModelIndex()) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; - int rowCount(QModelIndex const& parent - = QModelIndex()) const Q_DECL_OVERRIDE; + icclient_ord_order* data() { return m_data; } + void setData(icclient_ord_order* order); double subtotal() const { return m_subtotal; } 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(); @@ -69,10 +69,10 @@ namespace ICClient { private: void addItem(Item const& item); QList<Item> items; + icclient_ord_order* m_data; double m_subtotal; double m_shipping; double m_totalCost; - icclient_ord_order* order; }; } |