code formatting

This commit is contained in:
Martin Brodbeck 2022-07-07 15:37:33 +02:00
parent 5f7d91a18e
commit 6944051c31
18 changed files with 269 additions and 269 deletions

View file

@ -5,13 +5,13 @@
#include <QSettings>
BasketModel::BasketModel(Marketplace* market, QObject* parent)
: QAbstractTableModel(parent), marketplace_(market)
: QAbstractTableModel(parent), m_marketplace(market)
{
}
int BasketModel::rowCount([[maybe_unused]] const QModelIndex& parent) const
{
return static_cast<int>(marketplace_->basketSize());
return static_cast<int>(m_marketplace->basketSize());
}
int BasketModel::columnCount([[maybe_unused]] const QModelIndex& parent) const { return 4; }
@ -46,10 +46,10 @@ QVariant BasketModel::data(const QModelIndex& index, int role) const
if (role != Qt::DisplayRole)
return QVariant();
if (marketplace_->basketSize() == 0)
if (m_marketplace->basketSize() == 0)
return QVariant();
Article* article = marketplace_->getBasket().at(index.row()).get();
Article* article = m_marketplace->getBasket().at(index.row()).get();
switch (index.column()) {
case 0:
@ -92,45 +92,45 @@ QVariant BasketModel::headerData(int section, Qt::Orientation orientation, int r
void BasketModel::addArticle(Seller* seller, int price, const std::string& desc)
{
emit beginInsertRows(QModelIndex(), marketplace_->getBasket().size(),
marketplace_->getBasket().size());
emit beginInsertRows(QModelIndex(), m_marketplace->getBasket().size(),
m_marketplace->getBasket().size());
auto article = std::make_unique<Article>(price);
article->createUuid();
article->setDescription(desc);
article->setArticleNo(marketplace_->getNextArticleNo());
article->setArticleNo(m_marketplace->getNextArticleNo());
article->setSourceNo(QSettings().value("global/cashPointNo").toInt());
article->setSeller(seller);
marketplace_->addArticleToBasket(std::move(article));
m_marketplace->addArticleToBasket(std::move(article));
emit endInsertRows();
}
void BasketModel::finishSale()
{
emit beginRemoveRows(QModelIndex(), 0, marketplace_->getBasket().size() - 1);
emit beginRemoveRows(QModelIndex(), 0, m_marketplace->getBasket().size() - 1);
auto sale = std::make_unique<Sale>();
sale->createUuid();
sale->setSourceNo(QSettings().value("global/cashPointNo").toInt());
marketplace_->finishCurrentSale(std::move(sale));
m_marketplace->finishCurrentSale(std::move(sale));
emit endRemoveRows();
emit basketDataChanged();
}
void BasketModel::cancelSale()
{
emit beginRemoveRows(QModelIndex(), 0, marketplace_->getBasket().size() - 1);
marketplace_->getBasket().clear();
emit beginRemoveRows(QModelIndex(), 0, m_marketplace->getBasket().size() - 1);
m_marketplace->getBasket().clear();
emit endRemoveRows();
}
bool BasketModel::removeRows(int row, int count, const QModelIndex& parent)
{
auto article = marketplace_->getBasket().at(row).get();
auto article = m_marketplace->getBasket().at(row).get();
emit beginRemoveRows(parent, row, row + count - 1);
marketplace_->getBasket().erase(
std::remove_if(marketplace_->getBasket().begin(), marketplace_->getBasket().end(),
m_marketplace->getBasket().erase(
std::remove_if(m_marketplace->getBasket().begin(), m_marketplace->getBasket().end(),
[&article](const auto& a) { return a->getUuid() == article->getUuid(); }),
marketplace_->getBasket().end());
m_marketplace->getBasket().end());
emit endRemoveRows();
return true;
}