2018-07-21 19:24:56 +02:00
|
|
|
#include "pricedialog.h"
|
|
|
|
|
2018-07-22 20:56:20 +02:00
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2018-10-17 09:09:54 +02:00
|
|
|
PriceDialog::PriceDialog(QWidget* parent, bool forceDesc, Qt::WindowFlags f) : QDialog(parent, f)
|
2018-07-21 19:24:56 +02:00
|
|
|
{
|
2022-07-07 15:37:33 +02:00
|
|
|
m_forceDesc = forceDesc;
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
m_ui.priceSpinBox->setFocus();
|
2018-07-21 19:24:56 +02:00
|
|
|
}
|
|
|
|
|
2022-07-07 15:37:33 +02:00
|
|
|
int PriceDialog::getPrice() const { return static_cast<int>(m_ui.priceSpinBox->value() * 100); }
|
2018-07-22 20:56:20 +02:00
|
|
|
|
2022-07-07 15:37:33 +02:00
|
|
|
std::string PriceDialog::getDescription() const { return m_ui.descEdit->text().toStdString(); }
|
2018-08-07 09:27:15 +02:00
|
|
|
|
2018-07-22 20:56:20 +02:00
|
|
|
void PriceDialog::accept()
|
2018-07-21 19:24:56 +02:00
|
|
|
{
|
2022-07-07 15:37:33 +02:00
|
|
|
if (static_cast<int>(std::round(m_ui.priceSpinBox->value() * 100.0L)) % 50 != 0) {
|
2018-07-22 20:56:20 +02:00
|
|
|
QMessageBox(QMessageBox::Icon::Warning, "Falsche Preiseingabe",
|
2018-07-23 08:21:05 +02:00
|
|
|
"Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok,
|
|
|
|
this)
|
2018-07-22 20:56:20 +02:00
|
|
|
.exec();
|
2022-07-07 15:37:33 +02:00
|
|
|
} else if (m_forceDesc && m_ui.descEdit->text().trimmed().isEmpty()) {
|
2018-10-17 09:09:54 +02:00
|
|
|
QMessageBox(QMessageBox::Icon::Warning, "Artikelbeschreibung fehlt",
|
|
|
|
"Da Sie auf das Sonderkonto buchen ist eine Artikelbeschreibung erforderlich.",
|
|
|
|
QMessageBox::StandardButton::Ok, this)
|
|
|
|
.exec();
|
2022-07-07 15:37:33 +02:00
|
|
|
m_ui.descEdit->setFocus();
|
2018-07-22 20:56:20 +02:00
|
|
|
} else {
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
2018-10-17 09:09:54 +02:00
|
|
|
}
|
|
|
|
|
2022-07-07 15:37:33 +02:00
|
|
|
void PriceDialog::setForceDesc(bool force) { m_forceDesc = force; }
|