UI for load and save receipts.
parent
a8f4ad4a04
commit
5e7549d8a6
@ -1,14 +1,58 @@
|
|||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "receiptloadform.h"
|
#include "receiptloadform.h"
|
||||||
#include "ui_receiptloadform.h"
|
#include "ui_receiptloadform.h"
|
||||||
|
#include "shopservice.h"
|
||||||
|
#include "shop-odb.hxx"
|
||||||
|
|
||||||
ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
|
ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ReceiptLoadForm)
|
ui(new Ui::ReceiptLoadForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_voucherModel = new AutoTableModel<Voucher>(this);
|
||||||
|
ShopService srv;
|
||||||
|
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(5);
|
||||||
|
ui->tabVouchers->hideColumn(6);
|
||||||
|
ui->tabVouchers->hideColumn(7);
|
||||||
|
ui->tabVouchers->hideColumn(8);
|
||||||
|
ui->tabVouchers->hideColumn(10);
|
||||||
|
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||||
|
ui->tabVouchers->setColumnWidth(0, 190);
|
||||||
|
ui->tabVouchers->setColumnWidth(2, 200);
|
||||||
|
|
||||||
|
m_itemModel = new AutoTableModel<VoucherItem>(this);
|
||||||
|
ui->tabItems->setModel(m_itemModel);
|
||||||
|
|
||||||
|
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, QModelIndex){
|
||||||
|
ShopService srv;
|
||||||
|
VoucherPtr voucher = m_voucherModel->itemFromIndex(current);
|
||||||
|
srv.loadItems(voucher);
|
||||||
|
m_itemModel->setData(voucher->items());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiptLoadForm::~ReceiptLoadForm()
|
ReceiptLoadForm::~ReceiptLoadForm()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSortFilterProxyModel proxy;
|
||||||
|
proxy.setSourceModel(m_voucherModel);
|
||||||
|
proxy.setFilterKeyColumn(0);
|
||||||
|
proxy.setFilterFixedString(text);
|
||||||
|
|
||||||
|
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
|
||||||
|
if(matchingIndex.isValid()){
|
||||||
|
ui->tabVouchers->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);
|
||||||
|
ui->tabVouchers->setCurrentIndex(matchingIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue