From 4f2380f3dbb8caf43c70bbc20f2439a1929677e6 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 14 Jul 2019 15:53:58 +0200 Subject: [PATCH] Added checkbox for select all items from saved receipt. --- core/autotablemodel.h | 18 ++++++++++++++++++ shop/receiptloadform.cpp | 5 +++++ shop/receiptloadform.h | 2 ++ shop/receiptloadform.ui | 16 +++++++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/core/autotablemodel.h b/core/autotablemodel.h index 1fd9aed..a45046e 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -221,6 +221,24 @@ public: return ret; } + void setSelectAll(bool select) { + if (!m_checkboxSelect) { + return; + } + + beginResetModel(); + m_selectedRows.clear(); + + if (select) + { + for (int i = 0; i < rowCount(); i++) + { + m_selectedRows << i; + } + } + endResetModel(); + } + protected: void handleFilter(const QString &filter) override { diff --git a/shop/receiptloadform.cpp b/shop/receiptloadform.cpp index 2096c6e..9b9eba9 100644 --- a/shop/receiptloadform.cpp +++ b/shop/receiptloadform.cpp @@ -77,3 +77,8 @@ void ReceiptLoadForm::on_lineEdit_textChanged(const QString &text) ui->tabVouchers->setCurrentIndex(matchingIndex); } } + +void ReceiptLoadForm::on_selectAllCheck_clicked(bool checked) +{ + m_itemModel->setSelectAll(checked); +} diff --git a/shop/receiptloadform.h b/shop/receiptloadform.h index f49954d..8fb8462 100644 --- a/shop/receiptloadform.h +++ b/shop/receiptloadform.h @@ -22,6 +22,8 @@ public: private slots: void on_lineEdit_textChanged(const QString &text); + void on_selectAllCheck_clicked(bool checked); + private: Ui::ReceiptLoadForm *ui; AutoTableModel *m_voucherModel; diff --git a/shop/receiptloadform.ui b/shop/receiptloadform.ui index 697bec1..983c09c 100644 --- a/shop/receiptloadform.ui +++ b/shop/receiptloadform.ui @@ -50,7 +50,21 @@ - + + + Select &all + + + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + +