remove article (incomplete)
This commit is contained in:
parent
99bc19f7a3
commit
9ab8ca7a4b
3 changed files with 30 additions and 7 deletions
|
@ -165,4 +165,26 @@ void SaleModel::onBasketDataChanged()
|
|||
return lhs->getTimestamp() > rhs->getTimestamp();
|
||||
});
|
||||
emit endResetModel();
|
||||
}
|
||||
|
||||
bool SaleModel::removeRows(int row, int count, const QModelIndex& parent)
|
||||
{
|
||||
if (!parent.isValid()) {
|
||||
// remove complete sale
|
||||
|
||||
} 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);
|
||||
articles.at(row)->setState(Article::State::DELETE);
|
||||
sale->removeArticle(articles.at(row));
|
||||
marketplace_->storeToDb();
|
||||
if (articles.size() == 0) {
|
||||
std::cout << "No articles left.\n";
|
||||
}
|
||||
emit endRemoveRows();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue