36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#include "pricedialog.h"
|
|
|
|
#include <cmath>
|
|
|
|
#include <QMessageBox>
|
|
|
|
PriceDialog::PriceDialog(QWidget* parent, bool forceDesc, Qt::WindowFlags f) : QDialog(parent, f)
|
|
{
|
|
m_forceDesc = forceDesc;
|
|
m_ui.setupUi(this);
|
|
m_ui.priceSpinBox->setFocus();
|
|
}
|
|
|
|
int PriceDialog::getPrice() const { return static_cast<int>(m_ui.priceSpinBox->value() * 100); }
|
|
|
|
std::string PriceDialog::getDescription() const { return m_ui.descEdit->text().toStdString(); }
|
|
|
|
void PriceDialog::accept()
|
|
{
|
|
if (static_cast<int>(std::round(m_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 (m_forceDesc && m_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();
|
|
m_ui.descEdit->setFocus();
|
|
} else {
|
|
QDialog::accept();
|
|
}
|
|
}
|
|
|
|
void PriceDialog::setForceDesc(bool force) { m_forceDesc = force; } |