From bb5b136aea782d074e48433b97d598c2312088f2 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 23 May 2019 21:16:20 +0200 Subject: [PATCH] Optimized loading of vouchers for Paid Vouchers Dialog. --- shop/data/voucher.h | 6 +++++- shop/paydvouchersdialog.cpp | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/shop/data/voucher.h b/shop/data/voucher.h index 50efa76..0656cad 100644 --- a/shop/data/voucher.h +++ b/shop/data/voucher.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "voucheritem.h" @@ -171,6 +172,9 @@ public: QDateTime updated() const; void setUpdated(const QDateTime &updated); +#pragma db load(lazy) + odb::section m_itemsSection; + private: friend class odb::access; #pragma db id auto @@ -198,7 +202,7 @@ private: QString m_eetPkp; QString m_eetBkp; QString m_eetFik; - #pragma db value_not_null inverse(m_voucher) +#pragma db value_not_null inverse(m_voucher) section(m_itemsSection) QOdbList > m_items; VoucherStatus m_status; SeasonPtr m_season; diff --git a/shop/paydvouchersdialog.cpp b/shop/paydvouchersdialog.cpp index a326c36..a7ab8d2 100644 --- a/shop/paydvouchersdialog.cpp +++ b/shop/paydvouchersdialog.cpp @@ -2,7 +2,7 @@ #include "ui_paydvouchersdialog.h" #include -#include +#include #include "receiptgenerator.h" #include "shopservice.h" @@ -47,13 +47,12 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : ui->tableItems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); ui->tableItems->setColumnHidden(0, true); + ui->tableItems->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 30px; }"); ShopService srv; m_voucherModel->setData(srv.paiedVouchers()); ui->tableVouchers->sortByColumn(0,Qt::AscendingOrder); - - QScroller::grabGesture(ui->tableVouchers, QScroller::LeftMouseButtonGesture); - QScroller::grabGesture(ui->tableItems, QScroller::LeftMouseButtonGesture); + ui->tableVouchers->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 30px; }"); connect(ui->tableVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this, &srv](const QModelIndex ¤t, const QModelIndex &) { QSharedPointer voucher = m_voucherModel->itemFromIndex(current);