summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-13 18:17:49 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-13 18:17:49 +0800
commit5bd00e1499884e8458f58db86a6b92bc96da3e57 (patch)
tree03516f2759f44034a864e16e9d6eb82aa40629b9
parent3fc49f2f2838c69be14bcf60c6cf756825b2bbee (diff)
Method for updating quantity
-rw-r--r--interchange/ord.hxx8
-rw-r--r--ord.cxx20
2 files changed, 19 insertions, 9 deletions
diff --git a/interchange/ord.hxx b/interchange/ord.hxx
index 422d634..83fcce9 100644
--- a/interchange/ord.hxx
+++ b/interchange/ord.hxx
@@ -47,6 +47,10 @@ namespace QInterchange {
double totalCost() const { return m_totalCost; }
void setProfile(QString const& profile);
public slots:
+ void update(const QString &name,
+ const int quantity = 0,
+ const QString &orderPage = "",
+ const QString &nextPage = "");
void remove(const QString &name,
const QString &orderPage = "",
const QString &nextPage = "");
@@ -56,12 +60,12 @@ namespace QInterchange {
void subtotalChanged();
void shippingChanged();
void totalCostChanged();
- void removed(const QString &response);
+ void updated(const QString &response);
void gotTransaction(QString const& response);
protected:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- void emitRemoval(const QString &response);
+ void emitUpdate(const QString &response);
void emitTransaction(QString const& response);
private:
diff --git a/ord.cxx b/ord.cxx
index e4f4ec0..0a4e67c 100644
--- a/ord.cxx
+++ b/ord.cxx
@@ -89,8 +89,8 @@ namespace QInterchange {
if (this->profile != profile) this->profile = profile;
}
- void Ord::remove(const QString &name, const QString &orderPage,
- const QString &nextPage)
+ void Ord::update(const QString &name, const int quantity,
+ const QString &orderPage, const QString &nextPage)
{
item_name = (char *)malloc(name.size() + 1);
strcpy(item_name, name.toLatin1().constData());
@@ -106,16 +106,22 @@ namespace QInterchange {
next_page = (char *)malloc(nextPage.size() + 1);
strcpy(next_page, nextPage.toLatin1().constData());
}
- interchange_ord_remove(item_name, order_page, next_page,
- [](interchange_response *response) {
+ interchange_ord_update(item_name, quantity, order_page,
+ next_page, [](interchange_response *response) {
free(item_name);
if (order_page) free(order_page);
if (next_page) free(next_page);
- ord->emitRemoval(QString{response->data});
+ ord->emitUpdate(QString{response->data});
interchange_free_response(response);
});
}
+ void Ord::remove(const QString &name, const QString &orderPage,
+ const QString &nextPage)
+ {
+ update(name, 0, orderPage, nextPage);
+ }
+
void Ord::checkout(const Member& member)
{
order_profile = (char*)malloc(profile.size() + 1);
@@ -168,9 +174,9 @@ namespace QInterchange {
});
}
- void Ord::emitRemoval(const QString &response)
+ void Ord::emitUpdate(const QString &response)
{
- emit removed(response);
+ emit updated(response);
}
void Ord::emitTransaction(QString const& response)