diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2020-03-28 15:19:02 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2020-03-28 15:19:02 +0800 |
commit | 4681103c794fef10a0448d4378ca68ac77b6ee29 (patch) | |
tree | a7b411f744e730ded6877ec1b275a75f017b14e5 /qicclient | |
parent | a68fc492cf86a14cf9cf95d9f9a764cdf5b01007 (diff) | |
parent | 0728570b5a424abaad7fe49f63caa1977e016782 (diff) |
Merge branch 'master' into cmake
Diffstat (limited to 'qicclient')
-rw-r--r-- | qicclient/basket.hxx | 20 | ||||
-rw-r--r-- | qicclient/client.hxx | 15 |
2 files changed, 23 insertions, 12 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); diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 6121c5e..ef8a5bf 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -5,6 +5,7 @@ struct icclient_catalog; struct icclient_ord_order; +struct icclient_user; namespace ICClient { @@ -19,15 +20,21 @@ namespace ICClient { void allProducts(size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); + void order(icclient_ord_order** orderPtr, QString const& sku + , icclient_catalog* catalog); + void logIn(size_t (*handler)(void*, size_t, size_t, void*) + , icclient_user* user + , QString const& username + , QString const& password + , QString const& successPage = nullptr + , QString const& nextPage = nullptr + , QString const& failPage = nullptr); public slots: /* - void order(QString const& sku); void remove(unsigned int const& indices); void checkout(); */ - void logIn(QString const& username - , QString const& password); /* void account(QString const& firstName , QString const& lastName @@ -53,7 +60,7 @@ namespace ICClient { signals: void gotAllProducts(icclient_catalog* catalog); void ordered(icclient_ord_order* order); - void loggedIn(QString const& userName); + void loggedIn(icclient_user* user); void loggedOut(); }; |