create article with correct cash point no

This commit is contained in:
Martin Brodbeck 2018-07-30 13:49:23 +02:00
parent 9e85e2892d
commit c3b17fbb8b

View file

@ -1,6 +1,7 @@
#include "basketmodel.h" #include "basketmodel.h"
#include <QFont> #include <QFont>
#include <QSettings>
BasketModel::BasketModel(Marketplace* market, QObject* parent) BasketModel::BasketModel(Marketplace* market, QObject* parent)
: QAbstractTableModel(parent), marketplace_(market) : QAbstractTableModel(parent), marketplace_(market)
@ -79,20 +80,6 @@ QVariant BasketModel::headerData(int section, Qt::Orientation orientation, int r
return ""; return "";
} }
/* bool BasketModel::insertRows(int row, int count, const QModelIndex& parent)
{
//emit beginInsertRows(parent, row, row + count - 1);
//auto article = std::make_unique<Article>();
//article->createUuid();
//article->setArticleNo(marketplace_->getNextArticleNo());
//marketplace_->addArticleToBasket(std::move(article));
//emit endInsertRows();
emit layoutChanged();
return true;
} */
void BasketModel::addArticle(Seller* seller, int price) void BasketModel::addArticle(Seller* seller, int price)
{ {
emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(), emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(),
@ -100,8 +87,8 @@ void BasketModel::addArticle(Seller* seller, int price)
auto article = std::make_unique<Article>(price); auto article = std::make_unique<Article>(price);
article->createUuid(); article->createUuid();
article->setArticleNo(marketplace_->getNextArticleNo()); article->setArticleNo(marketplace_->getNextArticleNo());
article->setSourceNo(QSettings().value("global/cashPointNo").toInt());
article->setSeller(seller); article->setSeller(seller);
// std::cout << "!!! Neuer Artikel: " << article->getPrice() << " Cent \n";
marketplace_->addArticleToBasket(std::move(article)); marketplace_->addArticleToBasket(std::move(article));
emit endInsertRows(); emit endInsertRows();
} }