Compare commits
2 commits
17c65a50ea
...
fb8bcc71e2
Author | SHA1 | Date | |
---|---|---|---|
fb8bcc71e2 | |||
2003530587 |
3 changed files with 20 additions and 2 deletions
|
@ -49,7 +49,8 @@ void MainWindow::on_actionEditSeller_triggered()
|
|||
auto dialog = std::make_unique<SellerDialog>(this);
|
||||
int retCode = dialog->exec();
|
||||
|
||||
delete ui_.salesView->model();
|
||||
auto oldModel = ui_.salesView->model();
|
||||
ui_.salesView->setModel(nullptr);
|
||||
|
||||
if (retCode == QDialog::Accepted) {
|
||||
marketplace_->sortSellers();
|
||||
|
@ -63,6 +64,7 @@ void MainWindow::on_actionEditSeller_triggered()
|
|||
}
|
||||
|
||||
ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView));
|
||||
delete oldModel;
|
||||
ui_.salesView->setColumnHidden(2, true);
|
||||
ui_.salesView->resizeColumnToContents(0);
|
||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||
|
|
|
@ -9,8 +9,9 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
{
|
||||
ui_.setupUi(this);
|
||||
ui_.editButton->setVisible(false);
|
||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||
SellerModel* model =
|
||||
new SellerModel(dynamic_cast<MainWindow*>(parent)->getMarketplace(), ui_.tableView);
|
||||
new SellerModel(market_, ui_.tableView);
|
||||
ui_.tableView->setModel(model);
|
||||
ui_.tableView->setColumnHidden(0, true); // hide the uuid
|
||||
connect(ui_.newButton, &QPushButton::clicked, this, &SellerDialog::on_newButton_clicked);
|
||||
|
@ -21,6 +22,11 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
&SellerDialog::onSellerViewSelectionChanged);
|
||||
}
|
||||
|
||||
SellerDialog::~SellerDialog()
|
||||
{
|
||||
delete ui_.tableView->model();
|
||||
}
|
||||
|
||||
void SellerDialog::on_newButton_clicked()
|
||||
{
|
||||
ui_.tableView->reset();
|
||||
|
@ -38,6 +44,14 @@ void SellerDialog::on_deleteButton_clicked()
|
|||
if (selModel->hasSelection() == false)
|
||||
return;
|
||||
|
||||
if (market_->getSales().size() > 0) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Hinweis",
|
||||
"Da die Verkaufsphase schon begonnen hat (Artikel wurden bereits verkauft) können Sie keine Verkäufer mehr löschen.",
|
||||
QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
auto dlgResult =
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||
"Löschen wirkt sich direkt auf die Datenbank aus. Möchten Sie fortfahren?",
|
||||
|
|
|
@ -14,6 +14,7 @@ class SellerDialog : public QDialog
|
|||
public:
|
||||
SellerDialog(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||
~SellerDialog();
|
||||
|
||||
private slots:
|
||||
void onSellerViewSelectionChanged(const QItemSelection& selected,
|
||||
|
@ -25,6 +26,7 @@ class SellerDialog : public QDialog
|
|||
void on_model_duplicateSellerNo(const QString& message);
|
||||
virtual void accept() override;
|
||||
Ui::SellerDialog ui_;
|
||||
Marketplace* market_;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue