From a8f4ad4a04ae40c3bcc14e604c77c3ac87ec9a4c Mon Sep 17 00:00:00 2001 From: Rokos Josef Date: Tue, 21 Jun 2016 15:46:37 +0200 Subject: [PATCH] Save buttons on ShopForm are now disabled if no items on receipt. --- shop/shopform.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shop/shopform.cpp b/shop/shopform.cpp index e2cc34a..a6c74bf 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -15,6 +15,9 @@ ShopForm::ShopForm(QWidget *parent) : { ui->setupUi(this); m_itemsModel = NULL; + + ui->temporarySaveButton->setEnabled(false); + ui->saveButton->setEnabled(false); } ShopForm::~ShopForm() @@ -43,6 +46,8 @@ void ShopForm::loadLast() connectItemSignals(); 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; srv.calculate(m_voucher); 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) { @@ -158,6 +165,8 @@ void ShopForm::doTempSave(bool comboChanged) { m_voucher = srv.createVoucher(); ui->total->setText("0"); + ui->temporarySaveButton->setEnabled(false); + ui->saveButton->setEnabled(false); } fillRaceiptCombo(); @@ -181,6 +190,9 @@ void ShopForm::changeReceipt() m_itemsModel->setData(m_voucher->items()); ui->total->setText(m_voucher->totalPrice().toString()); + ui->temporarySaveButton->setEnabled(true); + ui->saveButton->setEnabled(true); + fillRaceiptCombo(); }