diff options
| author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-11-16 18:15:10 +0700 |
|---|---|---|
| committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-11-16 18:15:10 +0700 |
| commit | 501f86b2313538dec63834421806127383424771 (patch) | |
| tree | 02879dae14017f02f70ca084f7d6b1cc53414330 /basket.cxx | |
| parent | 87bf926c60712be2d6076c96bc9da659023f37bf (diff) | |
Same item in basket, gets removed and then inserted with new quantity
Diffstat (limited to 'basket.cxx')
| -rw-r--r-- | basket.cxx | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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) |