From 8a651871d06874737cfd3943568e58f945716a84 Mon Sep 17 00:00:00 2001 From: Zdenek Jonak Date: Tue, 25 Apr 2017 20:36:14 +0200 Subject: [PATCH 1/2] Changed sorting for payed bills to descending. closes #298 --- core/autotablemodel.h | 2 +- shop/paydvouchersdialog.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/autotablemodel.h b/core/autotablemodel.h index 2b12a38..f7ee949 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -151,7 +151,7 @@ public: const char *prop = rawEntity->metaObject()->property(column + 1).name(); std::sort(ALL(m_list), [prop, order](QSharedPointer entA, QSharedPointer entB) -> bool { - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { return ((QObject*)entA.data())->property(prop) < ((QObject*)entB.data())->property(prop); } else { return ((QObject*)entB.data())->property(prop) < ((QObject*)entA.data())->property(prop); diff --git a/shop/paydvouchersdialog.cpp b/shop/paydvouchersdialog.cpp index dee6199..72a1e09 100644 --- a/shop/paydvouchersdialog.cpp +++ b/shop/paydvouchersdialog.cpp @@ -16,11 +16,12 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : m_voucherModel = new AutoTableModel(this); m_itemModel = new AutoTableModel(this); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); + m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations()); ui->tableVouchers->setModel(m_voucherModel); ui->tableItems->setModel(m_itemModel); - + ui->tableVouchers->setSortingEnabled(true); ui->tableVouchers->setColumnHidden(2, true); ui->tableVouchers->setColumnHidden(6, true); ui->tableVouchers->setColumnHidden(7, true); @@ -43,6 +44,7 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : ShopService srv; m_voucherModel->setData(srv.paiedVouchers()); + ui->tableVouchers->sortByColumn(0,Qt::AscendingOrder); connect(ui->tableVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this, &srv](const QModelIndex ¤t, const QModelIndex &) { QSharedPointer voucher = m_voucherModel->itemFromIndex(current); From f85b1c75d338de5d15f7550b669d039a21015746 Mon Sep 17 00:00:00 2001 From: Zdenek Jonak Date: Tue, 25 Apr 2017 20:48:57 +0200 Subject: [PATCH 2/2] After unsuccessfull search is now text cleared. Useful for barcode scanners. closes #299 --- shop/shopform.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/shop/shopform.cpp b/shop/shopform.cpp index f5442be..cee9a9c 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -512,4 +512,5 @@ void ShopForm::on_commoditySearch_returnPressed() ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex()); addItem(item, ui->spnCount->value()); } + ui->commoditySearch->clear(); }