#include "pricedialog.h" #include #include PriceDialog::PriceDialog(QWidget* parent, bool forceDesc, Qt::WindowFlags f) : QDialog(parent, f) { forceDesc_ = forceDesc; ui_.setupUi(this); ui_.priceSpinBox->setFocus(); } int PriceDialog::getPrice() const { return static_cast(ui_.priceSpinBox->value() * 100); } std::string PriceDialog::getDescription() const { return ui_.descEdit->text().toStdString(); } void PriceDialog::accept() { if (static_cast(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) { QMessageBox(QMessageBox::Icon::Warning, "Falsche Preiseingabe", "Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok, this) .exec(); } else if (forceDesc_ && ui_.descEdit->text().trimmed().isEmpty()) { QMessageBox(QMessageBox::Icon::Warning, "Artikelbeschreibung fehlt", "Da Sie auf das Sonderkonto buchen ist eine Artikelbeschreibung erforderlich.", QMessageBox::StandardButton::Ok, this) .exec(); ui_.descEdit->setFocus(); } else { QDialog::accept(); } } void PriceDialog::setForceDesc(bool force) { forceDesc_ = force; }