check for 0,50 cent steps
This commit is contained in:
parent
ee8c059441
commit
97d05c93dd
2 changed files with 15 additions and 3 deletions
|
@ -1,12 +1,24 @@
|
|||
#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
|
||||
int PriceDialog::getPrice() const { return static_cast<int>(ui_.priceSpinBox->value() * 100); }
|
||||
|
||||
void PriceDialog::accept()
|
||||
{
|
||||
return static_cast<int>(ui_.priceSpinBox->value() * 100);
|
||||
if (static_cast<int>(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Falsche Preiseingabe",
|
||||
"Es sind 0,50 Cent-Schritte erlaubt", QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
} else {
|
||||
QDialog::accept();
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ class PriceDialog : public QDialog
|
|||
|
||||
private:
|
||||
void on_model_duplicateSellerNo(const QString& message);
|
||||
//virtual void accept() override;
|
||||
virtual void accept() override;
|
||||
Ui::PriceDialog ui_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue