Save buttons on ShopForm are now disabled if no items on receipt.

print
Rokos Josef 9 years ago
parent 6f84de2b6c
commit a8f4ad4a04

@ -15,6 +15,9 @@ ShopForm::ShopForm(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
m_itemsModel = NULL; m_itemsModel = NULL;
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
} }
ShopForm::~ShopForm() ShopForm::~ShopForm()
@ -43,6 +46,8 @@ void ShopForm::loadLast()
connectItemSignals(); connectItemSignals();
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2)); ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true);
} }
} }
@ -119,6 +124,8 @@ void ShopForm::onCountChanged()
ShopService srv; ShopService srv;
srv.calculate(m_voucher); srv.calculate(m_voucher);
ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2)); ui->total->setText(QString::number(m_voucher->totalPrice().toDouble(), 'f', 2));
ui->temporarySaveButton->setEnabled(!m_voucher->items().isEmpty());
ui->saveButton->setEnabled(!m_voucher->items().isEmpty());
if (m_voucher->status() == Voucher::NEW && m_voucher->id() == 0) if (m_voucher->status() == Voucher::NEW && m_voucher->id() == 0)
{ {
@ -158,6 +165,8 @@ void ShopForm::doTempSave(bool comboChanged)
{ {
m_voucher = srv.createVoucher(); m_voucher = srv.createVoucher();
ui->total->setText("0"); ui->total->setText("0");
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
} }
fillRaceiptCombo(); fillRaceiptCombo();
@ -181,6 +190,9 @@ void ShopForm::changeReceipt()
m_itemsModel->setData(m_voucher->items()); m_itemsModel->setData(m_voucher->items());
ui->total->setText(m_voucher->totalPrice().toString()); ui->total->setText(m_voucher->totalPrice().toString());
ui->temporarySaveButton->setEnabled(true);
ui->saveButton->setEnabled(true);
fillRaceiptCombo(); fillRaceiptCombo();
} }

Loading…
Cancel
Save