diff --git a/application/style.css b/application/style.css index b2628ea..05d94e4 100644 --- a/application/style.css +++ b/application/style.css @@ -19,4 +19,5 @@ color: white; font-weight: bold; min-width: 80px; + font: 10px; } diff --git a/core/roles/metaData.json b/core/roles/metaData.json index 0a3c398..b0a7561 100644 --- a/core/roles/metaData.json +++ b/core/roles/metaData.json @@ -2,7 +2,7 @@ "MetaData" : { "id" : "CORE_ROLES", "name" : { - "default" : "Core Roles plugin", + "default" : "Roles", "CZ" : "Role" }, "description" : { diff --git a/core/users/metaData.json b/core/users/metaData.json index 4041d59..b6cbdf7 100644 --- a/core/users/metaData.json +++ b/core/users/metaData.json @@ -2,7 +2,7 @@ "MetaData" : { "id" : "CORE_USERS", "name" : { - "default" : "Core Users plugin", + "default" : "Users", "CZ" : "Uživatelé" }, "description" : { diff --git a/shop/receiptloadform.cpp b/shop/receiptloadform.cpp index 9622c27..f293ec3 100644 --- a/shop/receiptloadform.cpp +++ b/shop/receiptloadform.cpp @@ -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(this); ui->tabItems->setModel(m_itemModel); + ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, 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)); diff --git a/shop/receiptloadform.ui b/shop/receiptloadform.ui index 4651ac7..792874f 100644 --- a/shop/receiptloadform.ui +++ b/shop/receiptloadform.ui @@ -31,7 +31,14 @@ - + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index 8106eb4..d85e476 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -26,16 +26,18 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer 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, 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; + foreach (QSharedPointer 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 = m_voucherModel->itemFromIndex(ui->tabVouchers->currentIndex()); + foreach (QSharedPointer item, m_voucher->items()) { + voucher->addItem(item); + } + + srv.calculate(voucher); + srv.updateVoucher(voucher); + srv.erase(m_voucher); + } + QDialog::accept(); } diff --git a/shop/receiptsaveform.ui b/shop/receiptsaveform.ui index aec56a6..58bc2f6 100644 --- a/shop/receiptsaveform.ui +++ b/shop/receiptsaveform.ui @@ -7,7 +7,7 @@ 0 0 804 - 513 + 578 @@ -51,6 +51,12 @@ 250 + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 0819eee..6ff678b 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -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"); });