more on sellers
This commit is contained in:
parent
a2ad2eb57d
commit
2812f582a1
7 changed files with 98 additions and 13 deletions
|
@ -2,11 +2,34 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
||||
{
|
||||
ui_.setupUi(this);
|
||||
SellerModel* model = new SellerModel(
|
||||
dynamic_cast<MainWindow*>(parent)->getMarketplace()->getSellers(), ui_.tableView);
|
||||
SellerModel* model =
|
||||
new SellerModel(dynamic_cast<MainWindow*>(parent)->getMarketplace(), ui_.tableView);
|
||||
ui_.tableView->setModel(model);
|
||||
ui_.tableView->setColumnHidden(0, true); // hide the uuid
|
||||
connect(ui_.newButton, &QPushButton::clicked, this, &SellerDialog::on_newButton_clicked);
|
||||
}
|
||||
|
||||
void SellerDialog::on_newButton_clicked()
|
||||
{
|
||||
ui_.tableView->model()->insertRows(ui_.tableView->model()->rowCount(), 1);
|
||||
ui_.tableView->scrollToBottom();
|
||||
}
|
||||
|
||||
void SellerDialog::accept()
|
||||
{
|
||||
Marketplace* market = dynamic_cast<MainWindow*>(parentWidget())->getMarketplace();
|
||||
for (const auto& seller : market->getSellers()) {
|
||||
if (seller->getFirstName().empty() || seller->getLastName().empty()) {
|
||||
QMessageBox(QMessageBox::Icon::Critical, "Fehler",
|
||||
"Bitte geben Sie bei jedem Verkäufer Vorname und Nachname an.",
|
||||
QMessageBox::StandardButton::Ok, this).exec();
|
||||
return;
|
||||
}
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue