This commit is contained in:
2017-02-17 15:21:57 +01:00
19 changed files with 781 additions and 48 deletions
+22 -2
View File
@@ -62,6 +62,7 @@ void ShopForm::loadLast()
if (m_commodityModel == NULL)
{
m_commodityModel = new AutoTableModel<ShopItem>(this);
m_commodityModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->commodityTable->setModel(m_commodityModel);
connect(ui->commodityTable->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, const QModelIndex &){
@@ -70,6 +71,8 @@ void ShopForm::loadLast()
}
m_commodityModel->setData(srv.allSellableItems());
ui->commodityTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->commodityTable->setColumnHidden(3, true);
}
void ShopForm::fillRaceiptCombo()
@@ -132,10 +135,27 @@ void ShopForm::on_loadButton_clicked()
{
ReceiptLoadForm *form = new ReceiptLoadForm(this);
form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){
ShopService srv;
if (m_voucher.isNull())
{
m_voucher = srv.createVoucher();
}
srv.moveItems(form->selectedItems(), form->selectedVoucher(), this->m_voucher);
m_itemsModel->setData(m_voucher->items());
connectItemSignals();
onCountChanged();
});
form->show();
}
void ShopForm::onCountChanged(int oldCount)
void ShopForm::onCountChanged(int oldCount/* = 0*/)
{
VoucherItem *item = qobject_cast<VoucherItem*>(sender());
if (item != NULL && item->count() == 0)
@@ -253,7 +273,7 @@ void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
srv.addShopItem(m_voucher, item, count);
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
onCountChanged(0);
onCountChanged();
}
void ShopForm::on_receiptCombo_currentIndexChanged(int)