diff --git a/src/gui/salemodel.cpp b/src/gui/salemodel.cpp index ae21dcb..2ef9959 100644 --- a/src/gui/salemodel.cpp +++ b/src/gui/salemodel.cpp @@ -171,6 +171,13 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent) { if (!parent.isValid()) { // remove complete sale + emit beginRemoveRows(parent, row, row + count - 1); + auto& sale = marketplace_->getSales().at(row); + sale->setState(Sale::State::DELETE); + std::for_each(sale->getArticles().begin(), sale->getArticles().end(), + [](auto& a) { a->setState(Article::State::DELETE); }); + marketplace_->storeToDb(); + emit endRemoveRows(); } else if (!parent.parent().isValid()) { // remove one article from a sale @@ -181,7 +188,6 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent) sale->removeArticle(articles.at(row)); emit endRemoveRows(); if (articles.size() == 0) { - std::cout << "No articles left.\n"; // marketplace_->removeSale(sale->getUuid()); sale->setState(Sale::State::DELETE); }