summaryrefslogtreecommitdiff
path: root/qicclient/basket.hxx
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-07-16 08:19:39 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-07-16 08:19:39 +0800
commite790f72bdbea00c353709dc5a9920527121eb57c (patch)
tree622a65b4ee9b5e8bd7aa7a9fede9d47b69d82378 /qicclient/basket.hxx
parent4ba15985b35566a99e822673fb355a4f4efa09fc (diff)
Rename basket to ord
Diffstat (limited to 'qicclient/basket.hxx')
-rw-r--r--qicclient/basket.hxx79
1 files changed, 0 insertions, 79 deletions
diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx
deleted file mode 100644
index 8930821..0000000
--- a/qicclient/basket.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef QICCLIENT_BASKET_HXX
-#define QICCLIENT_BASKET_HXX
-
-#include <QAbstractListModel>
-#include <icclient/ord.h>
-#include "product.hxx"
-
-namespace QICClient {
-
- struct Item
- {
- enum ItemRoles {
- QuantityRole = Product::PriceRole + 1
- };
-
- Item(icclient_ord_item* item)
- : product{item->product}
- , quantity{item->quantity}
- {}
-
- Product product;
- unsigned int quantity;
-
- bool operator==(Item const& item)
- {
- return product.sku == item.product.sku;
- }
- };
-
- class Basket : public QAbstractListModel
- {
- Q_OBJECT
- Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
- Q_PROPERTY(double subtotal READ subtotal NOTIFY subtotalChanged)
- Q_PROPERTY(double shipping READ shipping NOTIFY shippingChanged)
- Q_PROPERTY(double totalCost READ totalCost NOTIFY totalCostChanged)
-
- public:
- explicit Basket(QObject* parent = nullptr) :
- QAbstractListModel{parent},
- m_data{nullptr},
- 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;
-
- struct icclient_ord_order* data() { return m_data; }
- void setData(struct icclient_ord_order* order);
- double subtotal() const { return m_subtotal; }
- double shipping() const { return m_shipping; }
- double totalCost() const { return m_totalCost; }
-
- signals:
- void rowCountChanged();
- void subtotalChanged();
- void shippingChanged();
- void totalCostChanged();
-
- protected:
- QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
-
- private:
- void addItem(Item const& item);
- QList<Item> items;
- struct icclient_ord_order* m_data;
- double m_subtotal;
- double m_shipping;
- double m_totalCost;
- };
-
-}
-
-#endif // QICCLIENT_BASKET_HXX