cancel sale button activated
This commit is contained in:
parent
a130fa33c2
commit
99bc19f7a3
3 changed files with 41 additions and 1 deletions
|
@ -36,8 +36,12 @@ MainWindow::MainWindow()
|
|||
connect(ui_.paidButton, &QPushButton::clicked, this, &MainWindow::onPaidButtonTriggered);
|
||||
connect(ui_.basketView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&MainWindow::onBasketViewSelectionChanged);
|
||||
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&MainWindow::onSalesViewSelectionChanged);
|
||||
connect(ui_.cancelArticleButton, &QPushButton::clicked, this,
|
||||
&MainWindow::onCancelArticleButtonClicked);
|
||||
connect(ui_.cancelSaleButton, &QPushButton::clicked, this,
|
||||
&MainWindow::onCancelSaleButtonClicked);
|
||||
connect(ui_.cancelAllArticlesButton, &QPushButton::clicked, this,
|
||||
&MainWindow::onCancelAllArticlesButtonClicked);
|
||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||
|
@ -128,6 +132,16 @@ void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected,
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSalesViewSelectionChanged(const QItemSelection& selected,
|
||||
[[maybe_unused]] const QItemSelection& deselected)
|
||||
{
|
||||
if (selected.size() > 0) {
|
||||
ui_.cancelSaleButton->setEnabled(true);
|
||||
} else {
|
||||
ui_.cancelSaleButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
|
||||
{
|
||||
auto selModel = ui_.basketView->selectionModel();
|
||||
|
@ -151,6 +165,29 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
|
||||
{
|
||||
auto selModel = ui_.salesView->selectionModel();
|
||||
if (selModel->hasSelection() == false)
|
||||
return;
|
||||
|
||||
auto dlgResult =
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||
"Möchten Sie wirklich stornieren?",
|
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
||||
.exec();
|
||||
if (dlgResult == QMessageBox::No)
|
||||
return;
|
||||
|
||||
auto indexes = selModel->selectedRows();
|
||||
std::sort(indexes.begin(), indexes.end());
|
||||
|
||||
// Deleting the rows, beginning with the last one!
|
||||
for (auto iter = indexes.constEnd() - 1; iter >= indexes.constBegin(); --iter) {
|
||||
ui_.salesView->model()->removeRow(iter->row());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||
{
|
||||
if (ui_.basketView->model()->rowCount() == 0)
|
||||
|
|
|
@ -20,7 +20,10 @@ class MainWindow : public QMainWindow
|
|||
private slots:
|
||||
void onBasketViewSelectionChanged(const QItemSelection& selected,
|
||||
const QItemSelection& deselected);
|
||||
void onSalesViewSelectionChanged(const QItemSelection& selected,
|
||||
const QItemSelection& deselected);
|
||||
void onCancelArticleButtonClicked(bool checked);
|
||||
void onCancelSaleButtonClicked(bool checked);
|
||||
void onCancelAllArticlesButtonClicked(bool checked);
|
||||
|
||||
private:
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="cancelSaleButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
|
Loading…
Reference in a new issue