summaryrefslogtreecommitdiff
path: root/ord.cxx
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 18:57:01 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 18:57:01 +0800
commitc8ed6cbb4a3a9051fcc2536fd6e751da7a3264cf (patch)
treea5beba996759bf4cced505efd0333fa52456f407 /ord.cxx
parentf70a1a57d83e4f50a7221d13b173a156ef0eb6cf (diff)
Item & Ord are with constructed with copies, not pointers
Diffstat (limited to 'ord.cxx')
-rw-r--r--ord.cxx24
1 files changed, 7 insertions, 17 deletions
diff --git a/ord.cxx b/ord.cxx
index f7e2161..7cf1e52 100644
--- a/ord.cxx
+++ b/ord.cxx
@@ -8,25 +8,15 @@ namespace QInterchange {
static Ord* ord;
static char* order_profile;
- Ord::Ord(struct interchange_ord_order *order, QObject* parent) :
- QAbstractListModel{parent},
- m_data{nullptr},
- m_subtotal{.0},
- m_shipping{.0},
- m_totalCost{.0}
+ Ord::Ord(struct interchange_ord_order order, QObject* parent) :
+ QAbstractListModel{parent}
{
ord = this;
- if (!order) return;
- for (size_t i = 0; i < order->nitems; i++)
- addItem(Item{order->items[i]});
- m_subtotal = order->subtotal;
- m_totalCost = order->total_cost;
- m_data = order;
- }
-
- Ord::~Ord()
- {
- if (m_data) interchange_ord_free_order(m_data);
+ for (size_t i = 0; i < order.nitems; i++)
+ addItem(Item{order.items[i]});
+ m_subtotal = order.subtotal;
+ m_shipping = order.shipping;
+ m_totalCost = order.total_cost;
}
int Ord::rowCount(QModelIndex const& parent) const