From 1d0dc942aaed38ce2d4c4b8c8f078dd945c7e633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Mon, 6 Feb 2023 02:11:31 +0800 Subject: Interface for setting order profile --- interchange/ord.hxx | 5 +++++ ord.cxx | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/interchange/ord.hxx b/interchange/ord.hxx index 5b14d96..57b1797 100644 --- a/interchange/ord.hxx +++ b/interchange/ord.hxx @@ -39,6 +39,10 @@ namespace QInterchange { m_subtotal{.0}, m_shipping{.0}, m_totalCost{.0} {} + ~Ord() + { + if (m_data->profile) free(m_data->profile); + } int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; @@ -47,6 +51,7 @@ namespace QInterchange { double subtotal() const { return m_subtotal; } double shipping() const { return m_shipping; } double totalCost() const { return m_totalCost; } + void setProfile(QString const& profile); public slots: // void remove(unsigned int const& indices); void checkout(Member& member); diff --git a/ord.cxx b/ord.cxx index 8d76dce..35b496c 100644 --- a/ord.cxx +++ b/ord.cxx @@ -71,6 +71,14 @@ namespace QInterchange { emit totalCostChanged(); } + void Ord::setProfile(QString const& profile) + { + auto orderProfile = profile.toLatin1().data(); + if (m_data->profile) free(m_data->profile); + m_data->profile = (char*)malloc(strlen(orderProfile) + 1); + strcpy(m_data->profile, orderProfile); + } + void Ord::checkout(Member& member) { interchange_ord_checkout(m_data, member.data()); -- cgit v1.2.3