diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-20 19:27:57 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-20 19:27:57 +0800 |
commit | ef95b0d6d69c44ee47d6d4107720e7313b46c11b (patch) | |
tree | 2e29c819012310ad434617803cf1bab368283813 | |
parent | 0cf7dbaca13dbdcbc1dc913de7d32d023cb1a970 (diff) |
Simplify member functions
-rw-r--r-- | client.cxx | 35 | ||||
-rw-r--r-- | qicclient.hxx | 6 |
2 files changed, 17 insertions, 24 deletions
@@ -16,46 +16,37 @@ namespace QICClient { icclient_cleanup(); } - static void catalogHandler(icclient_response* response) - { - client->emitCatalog(QString{response->data}); - icclient_free_response(response); - } - - static void catalogCallback(struct icclient_catalog* catalog) - { - icclient_free_catalog(catalog); - } - void Client::catalog(QString const& prodGroup) { - icclient_catalog(prodGroup.toLatin1().constData(), catalogHandler, nullptr); + icclient_catalog(prodGroup.toLatin1().constData(), [](icclient_response* response) { + client->emitCatalog(QString{response->data}); + icclient_free_response(response); + }, nullptr); } void Client::allProducts() { - icclient_allproducts(catalogHandler, nullptr); - } - - static void productHandler(icclient_response* response) - { - client->emitProduct(QString{response->data}); - icclient_free_response(response); + catalog("All-Products"); } void Client::product(QString const& sku) { - icclient_product(sku.toLatin1().constData(), productHandler, nullptr); + icclient_product(sku.toLatin1().constData(), [](icclient_response* response) { + client->emitProduct(QString{response->data}); + icclient_free_response(response); + }, nullptr); } void Client::defaultCatalog(QString const& prodGroup) { - icclient_catalog(prodGroup.toLatin1().constData(), nullptr, catalogCallback); + icclient_catalog(prodGroup.toLatin1().constData(), nullptr, [](struct icclient_catalog* catalog) { + icclient_free_catalog(catalog); + }); } void Client::defaultAllProducts() { - icclient_allproducts(nullptr, catalogCallback); + defaultCatalog("All-Products"); } void Client::emitCatalog(QString const& catalog) diff --git a/qicclient.hxx b/qicclient.hxx index da1fa61..664b566 100644 --- a/qicclient.hxx +++ b/qicclient.hxx @@ -31,8 +31,6 @@ namespace QICClient { * \param order The order. */ void order(QString const& sku, Catalog const& catalog, Ord& order); - void emitCatalog(QString const& response); - void emitProduct(QString const& response); public slots: /*! @@ -62,6 +60,10 @@ namespace QICClient { signals: void gotCatalog(QString const& response); void gotProduct(QString const& response); + + protected: + void emitCatalog(QString const& response); + void emitProduct(QString const& response); }; } |