delete sales

This commit is contained in:
Martin Brodbeck 2018-07-28 11:52:43 +02:00
parent 9ab8ca7a4b
commit 940688edd5
6 changed files with 27 additions and 6 deletions

View file

@ -175,14 +175,18 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent)
} else if (!parent.parent().isValid()) {
// remove one article from a sale
auto sale = static_cast<Sale*>(parent.internalPointer());
auto articles = sale->getArticles();
emit beginRemoveRows(parent, row, row + count -1);
auto& articles = sale->getArticles();
articles.at(row)->setState(Article::State::DELETE);
emit beginRemoveRows(parent, row, row + count - 1);
sale->removeArticle(articles.at(row));
marketplace_->storeToDb();
emit endRemoveRows();
if (articles.size() == 0) {
std::cout << "No articles left.\n";
// marketplace_->removeSale(sale->getUuid());
sale->setState(Sale::State::DELETE);
}
emit beginRemoveRows(parent.parent(), 0, 0);
marketplace_->storeToDb();
emit endRemoveRows();
}