27 lines
No EOL
782 B
C++
27 lines
No EOL
782 B
C++
#include "pricedialog.h"
|
|
|
|
#include <cmath>
|
|
|
|
#include <QMessageBox>
|
|
|
|
PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
|
{
|
|
ui_.setupUi(this);
|
|
ui_.priceSpinBox->setFocus();
|
|
}
|
|
|
|
int PriceDialog::getPrice() const { return static_cast<int>(ui_.priceSpinBox->value() * 100); }
|
|
|
|
std::string PriceDialog::getDescription() const { return ui_.descEdit->text().toStdString(); }
|
|
|
|
void PriceDialog::accept()
|
|
{
|
|
if (static_cast<int>(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 {
|
|
QDialog::accept();
|
|
}
|
|
} |