print
Josef Rokos 8 years ago
parent f9d7df9ab5
commit 452d58ac4f

@ -19,4 +19,5 @@
color: white;
font-weight: bold;
min-width: 80px;
font: 10px;
}

@ -2,7 +2,7 @@
"MetaData" : {
"id" : "CORE_ROLES",
"name" : {
"default" : "Core Roles plugin",
"default" : "Roles",
"CZ" : "Role"
},
"description" : {

@ -2,7 +2,7 @@
"MetaData" : {
"id" : "CORE_USERS",
"name" : {
"default" : "Core Users plugin",
"default" : "Users",
"CZ" : "Uživatelé"
},
"description" : {

@ -16,19 +16,22 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel);
ui->tabVouchers->hideColumn(3);
ui->tabVouchers->hideColumn(4);
ui->tabVouchers->hideColumn(0);
ui->tabVouchers->hideColumn(1);
ui->tabVouchers->hideColumn(5);
ui->tabVouchers->hideColumn(6);
ui->tabVouchers->hideColumn(7);
ui->tabVouchers->hideColumn(8);
ui->tabVouchers->hideColumn(9);
ui->tabVouchers->hideColumn(10);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(0, 190);
ui->tabVouchers->setColumnWidth(2, 200);
ui->tabVouchers->hideColumn(12);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(3, 200);
ui->tabVouchers->setColumnWidth(4, 200);
m_itemModel = new AutoTableModel<VoucherItem>(this);
ui->tabItems->setModel(m_itemModel);
ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, QModelIndex){
ShopService srv;
@ -47,7 +50,7 @@ void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text)
{
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_voucherModel);
proxy.setFilterKeyColumn(0);
proxy.setFilterKeyColumn(2);
proxy.setFilterFixedString(text);
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));

@ -31,7 +31,14 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QTableView" name="tabVouchers"/>
<widget class="QTableView" name="tabVouchers">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
</widget>

@ -26,16 +26,18 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel);
ui->tabVouchers->hideColumn(3);
ui->tabVouchers->hideColumn(4);
ui->tabVouchers->hideColumn(0);
ui->tabVouchers->hideColumn(1);
ui->tabVouchers->hideColumn(5);
ui->tabVouchers->hideColumn(6);
ui->tabVouchers->hideColumn(7);
ui->tabVouchers->hideColumn(8);
ui->tabVouchers->hideColumn(9);
ui->tabVouchers->hideColumn(10);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(0, 190);
ui->tabVouchers->setColumnWidth(2, 200);
ui->tabVouchers->hideColumn(12);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
ui->tabVouchers->setColumnWidth(3, 200);
ui->tabVouchers->setColumnWidth(4, 200);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
@ -45,9 +47,15 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
m_binder.setData(new Voucher);
AddressBookService srvAdb;
m_binder.registerBinding(ui->contact, ComboData::createComboData(srvAdb.all()));
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->name);
m_binder.registerBinding(ui->description);
m_binder.bindToUi();
@ -70,7 +78,7 @@ void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text)
{
QSortFilterProxyModel proxy;
proxy.setSourceModel(m_voucherModel);
proxy.setFilterKeyColumn(0);
proxy.setFilterKeyColumn(2);
proxy.setFilterFixedString(text);
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
@ -103,6 +111,24 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
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();
}

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>804</width>
<height>513</height>
<height>578</height>
</rect>
</property>
<property name="windowTitle">
@ -51,6 +51,12 @@
<height>250</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>

@ -105,10 +105,7 @@ void ShopForm::on_saveButton_clicked()
form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this]() {
ShopService srv;
m_voucher->setStatus(Voucher::NOT_PAID);
srv.saveVoucher(m_voucher);
m_voucher = srv.createVoucher();
createEmptyVoucher();
m_itemsModel->setData(m_voucher->items());
ui->total->setText("0");
});

Loading…
Cancel
Save