From 0a94e177d28a1257dbe9cd4b8ff3c97fba3dfd46 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Mon, 7 Oct 2019 10:21:33 +0800 Subject: Make a header inclusion more correct --- qicclient/catalog.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qicclient') diff --git a/qicclient/catalog.hxx b/qicclient/catalog.hxx index d539149..38e257a 100644 --- a/qicclient/catalog.hxx +++ b/qicclient/catalog.hxx @@ -2,7 +2,7 @@ #define QICCLIENT_CATALOG_HXX #include -#include +#include "product.hxx" struct icclient_catalog; -- cgit v1.3 From 560a47463ec705715b4ce5f53a39030feb48e305 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Tue, 22 Oct 2019 18:08:56 +0800 Subject: order is not a slot and takes a catalog argument --- catalog.cxx | 1 - client.cxx | 6 ++++++ libicclient | 2 +- qicclient/client.hxx | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'qicclient') diff --git a/catalog.cxx b/catalog.cxx index ecc01a0..8cdc64a 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -57,7 +57,6 @@ namespace ICClient { if (catalog) { for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); - icclient_freecatalog(catalog); emit updated(); } } diff --git a/client.cxx b/client.cxx index 7ffe780..d3146ce 100644 --- a/client.cxx +++ b/client.cxx @@ -21,6 +21,12 @@ namespace ICClient { emit gotAllProducts(catalog); } + void Client::order(QString const& sku, icclient_catalog* catalog) + { + icclient_ord_order* order = nullptr; + icclient_order(&order, sku.toLatin1().constData(), catalog); + } + void Client::logIn(QString const& username, QString const& password) { icclient_login(username.toLatin1().constData() diff --git a/libicclient b/libicclient index 6fa0df3..e8ae8fb 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 6fa0df3c46986b15dec3be672f41eb7ea62c20ef +Subproject commit e8ae8fbeab89beb43138e26465965d3510edd1c7 diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 6121c5e..470018a 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -19,10 +19,10 @@ namespace ICClient { void allProducts(size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); + void order(QString const& sku, icclient_catalog* catalog); public slots: /* - void order(QString const& sku); void remove(unsigned int const& indices); void checkout(); */ -- cgit v1.3 From d7b7252da7f110d8903250c83109cd73e6b2de34 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Mon, 4 Nov 2019 19:17:53 +0700 Subject: order function takes a pointer to order argument --- client.cxx | 7 ++++--- libicclient | 2 +- qicclient/client.hxx | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'qicclient') diff --git a/client.cxx b/client.cxx index 74a64ba..1dad6fe 100644 --- a/client.cxx +++ b/client.cxx @@ -21,10 +21,11 @@ namespace ICClient { emit gotAllProducts(catalog); } - void Client::order(QString const& sku, icclient_catalog* catalog) + void Client::order(icclient_ord_order** orderPtr, QString const& sku + , icclient_catalog* catalog) { - icclient_ord_order* order = nullptr; - icclient_order(&order, sku.toLatin1().constData(), catalog); + icclient_order(orderPtr, sku.toLatin1().constData(), catalog); + icclient_ord_order* order = *orderPtr; emit ordered(order); } diff --git a/libicclient b/libicclient index 0bef9b7..e26a6b8 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 0bef9b7717ecff9544284f5ba4b7576dadad4892 +Subproject commit e26a6b81a2b489a177e5916c54a3a9c59edd3a12 diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 470018a..893e47b 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -19,7 +19,8 @@ namespace ICClient { void allProducts(size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); - void order(QString const& sku, icclient_catalog* catalog); + void order(icclient_ord_order** orderPtr, QString const& sku + , icclient_catalog* catalog); public slots: /* -- cgit v1.3 From 501f86b2313538dec63834421806127383424771 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Sat, 16 Nov 2019 18:15:10 +0700 Subject: Same item in basket, gets removed and then inserted with new quantity --- basket.cxx | 18 +++++++++++------- qicclient/basket.hxx | 5 +++++ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'qicclient') diff --git a/basket.cxx b/basket.cxx index 60ea273..52dca83 100644 --- a/basket.cxx +++ b/basket.cxx @@ -47,13 +47,17 @@ namespace ICClient { , [&product](Item const& item) { return product.sku == item.product.sku; }); - if (iterator == items.end()) { - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - items << item; - endInsertRows(); - emit rowCountChanged(); - } else - iterator->quantity++; + if (iterator != items.end()) { + auto index = items.indexOf(*iterator); + beginRemoveRows(QModelIndex(), index, index); + items.removeAt(index); + endRemoveRows(); + } + + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + items << item; + endInsertRows(); + emit rowCountChanged(); } void Basket::update(icclient_ord_order* order) diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx index b3b5e11..7b3de2a 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -22,6 +22,11 @@ namespace ICClient { Product product; unsigned int quantity; + + bool operator==(Item const& item) + { + return product.sku == item.product.sku; + } }; class Basket : public QAbstractListModel -- cgit v1.3 From 9dcfaa143432bd515639870db80c2682cb26e144 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Sat, 16 Nov 2019 18:42:08 +0700 Subject: Remove unused signal --- qicclient/basket.hxx | 1 - 1 file changed, 1 deletion(-) (limited to 'qicclient') diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx index 7b3de2a..101a6bc 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -62,7 +62,6 @@ namespace ICClient { QHash roleNames() const Q_DECL_OVERRIDE; signals: - void updated(); void subtotalChanged(); void shippingChanged(); void totalCostChanged(); -- cgit v1.3 From 5b388f581333d9d3eee1c993054354243be13183 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Sat, 16 Nov 2019 18:47:51 +0700 Subject: Reorder basket interface lines --- qicclient/basket.hxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'qicclient') diff --git a/qicclient/basket.hxx b/qicclient/basket.hxx index 101a6bc..ecd7a67 100644 --- a/qicclient/basket.hxx +++ b/qicclient/basket.hxx @@ -32,10 +32,10 @@ namespace ICClient { 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) @@ -45,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; } @@ -58,14 +58,14 @@ namespace ICClient { public slots: void update(icclient_ord_order* order); - protected: - QHash roleNames() const Q_DECL_OVERRIDE; - signals: + void rowCountChanged(); void subtotalChanged(); void shippingChanged(); void totalCostChanged(); - void rowCountChanged(); + + protected: + QHash roleNames() const Q_DECL_OVERRIDE; private: void addItem(Item const& item); -- cgit v1.3 From 2bf032f097da081fc45ff7249f789bdfe142fd28 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Mon, 18 Nov 2019 19:25:35 +0700 Subject: logIn takes page arguments and is not a slot any more --- client.cxx | 10 +++++++--- qicclient/client.hxx | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'qicclient') diff --git a/client.cxx b/client.cxx index 1dad6fe..0aafc46 100644 --- a/client.cxx +++ b/client.cxx @@ -29,11 +29,15 @@ namespace ICClient { emit ordered(order); } - void Client::logIn(QString const& username, QString const& password) + void Client::logIn(QString const& username, QString const& password + , QString const& successPage, QString const& nextPage + , QString const& failPage) { icclient_login(username.toLatin1().constData() - , password.toLatin1().constData(), nullptr, nullptr - , nullptr); + , password.toLatin1().constData() + , successPage.toLatin1().constData() + , nextPage.toLatin1().constData() + , failPage.toLatin1().constData()); emit loggedIn(username); } diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 893e47b..47f25fb 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -21,14 +21,17 @@ namespace ICClient { , void* userdata)); void order(icclient_ord_order** orderPtr, QString const& sku , icclient_catalog* catalog); + void logIn(QString const& username + , QString const& password + , QString const& successPage = nullptr + , QString const& nextPage = nullptr + , QString const& failPage = nullptr); public slots: /* void remove(unsigned int const& indices); void checkout(); */ - void logIn(QString const& username - , QString const& password); /* void account(QString const& firstName , QString const& lastName -- cgit v1.3 From 7079898ae28c6cc417ba8eadc4bd2466886bbc63 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Sun, 29 Dec 2019 08:45:06 +0800 Subject: Add parameters for handler and user pointers to login related functions. These are the cURL write function and data respectively. --- client.cxx | 10 ++++++---- qicclient/client.hxx | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'qicclient') diff --git a/client.cxx b/client.cxx index 0aafc46..c0dd1c2 100644 --- a/client.cxx +++ b/client.cxx @@ -1,5 +1,6 @@ #include #include +#include #include "qicclient/client.hxx" namespace ICClient { @@ -29,11 +30,12 @@ namespace ICClient { emit ordered(order); } - void Client::logIn(QString const& username, QString const& password - , QString const& successPage, QString const& nextPage - , QString const& failPage) + void Client::logIn(size_t (*handler)(void*, size_t, size_t, void*) + , icclient_user* user, QString const& username + , QString const& password, QString const& successPage + , QString const& nextPage, QString const& failPage) { - icclient_login(username.toLatin1().constData() + icclient_login(handler, user, username.toLatin1().constData() , password.toLatin1().constData() , successPage.toLatin1().constData() , nextPage.toLatin1().constData() diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 47f25fb..0fb01f8 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 { @@ -21,7 +22,9 @@ namespace ICClient { , void* userdata)); void order(icclient_ord_order** orderPtr, QString const& sku , icclient_catalog* catalog); - void logIn(QString const& username + 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 -- cgit v1.3 From baefbee691355fccc6b64b0171d2f02959759a37 Mon Sep 17 00:00:00 2001 From: ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ Date: Sun, 29 Dec 2019 08:45:39 +0800 Subject: Change loggedIn signal parameter type to IC client user --- client.cxx | 2 +- qicclient/client.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qicclient') diff --git a/client.cxx b/client.cxx index c0dd1c2..8484387 100644 --- a/client.cxx +++ b/client.cxx @@ -40,7 +40,7 @@ namespace ICClient { , successPage.toLatin1().constData() , nextPage.toLatin1().constData() , failPage.toLatin1().constData()); - emit loggedIn(username); + emit loggedIn(user); } void Client::logOut() diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 0fb01f8..ef8a5bf 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -60,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(); }; -- cgit v1.3