35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
#include "sellerdialog.h"
|
|
|
|
#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(), 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();
|
|
} |