This commit is contained in:
2016-07-06 21:42:27 +02:00
56 changed files with 2170 additions and 238 deletions
+2 -32
View File
@@ -45,15 +45,9 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
m_binder.setData(new Voucher);
AddressBookService srvAdb;
QList<ComboData> comboData;
foreach (QSharedPointer<AddressbookData> adb, srvAdb.all()) {
comboData << ComboData(adb);
}
m_voucher = voucher;
m_binder.setData(m_voucher.data());
m_binder.registerBinding(ui->contact, comboData);
m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all()));
m_binder.registerBinding(ui->name);
m_binder.registerBinding(ui->description);
m_binder.bindToUi();
@@ -106,27 +100,3 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->name->text().isEmpty());
}
}
void ReceiptSaveForm::accept()
{
ShopService srv;
m_binder.bindToData();
if (m_saveAsNew)
{
m_voucher->setStatus(Voucher::NOT_PAID);
srv.updateVoucher(m_voucher);
}
else
{
QSharedPointer<Voucher> voucher = m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex());
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
voucher->addItem(item);
}
srv.calculate(voucher);
srv.updateVoucher(voucher);
srv.erase(m_voucher);
}
QDialog::accept();
}