diff options
Diffstat (limited to 'qicclient/basket.hxx')
-rw-r--r-- | qicclient/basket.hxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx index b3b5e11..ecd7a67 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -22,15 +22,20 @@ namespace ICClient { 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) - Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged) public: explicit Basket(QObject* parent = nullptr) @@ -40,11 +45,11 @@ namespace ICClient { , 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; double subtotal() const { return m_subtotal; } double shipping() const { return m_shipping; } @@ -53,15 +58,14 @@ namespace ICClient { public slots: void update(icclient_ord_order* order); - protected: - QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; - signals: - void updated(); + void rowCountChanged(); void subtotalChanged(); void shippingChanged(); void totalCostChanged(); - void rowCountChanged(); + + protected: + QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; private: void addItem(Item const& item); |