cancel sales / items finished
This commit is contained in:
parent
9c56ec55a5
commit
0a22faf856
1 changed files with 7 additions and 1 deletions
|
@ -171,6 +171,13 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent)
|
||||||
{
|
{
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
// remove complete sale
|
// 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()) {
|
} else if (!parent.parent().isValid()) {
|
||||||
// remove one article from a sale
|
// 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));
|
sale->removeArticle(articles.at(row));
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
if (articles.size() == 0) {
|
if (articles.size() == 0) {
|
||||||
std::cout << "No articles left.\n";
|
|
||||||
// marketplace_->removeSale(sale->getUuid());
|
// marketplace_->removeSale(sale->getUuid());
|
||||||
sale->setState(Sale::State::DELETE);
|
sale->setState(Sale::State::DELETE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue