-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowEditPosition.cpp
68 lines (55 loc) · 2.24 KB
/
windowEditPosition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "windowEditPosition.h"
#include "ui_windowEditPosition.h"
WindowEditPosition::WindowEditPosition(QWidget *parent, Positions *position) :
QDialog(parent),
ui(new Ui::WindowEditPosition),
m_position(position)
{
ui->setupUi(this);
printPosition();
}
WindowEditPosition::~WindowEditPosition()
{
delete ui;
}
void WindowEditPosition::printPosition()
{
ui->leEditPosPosition->setText(QString::number(m_position->getPos()));
ui->leEditPosArtNr->setText(QString::number(m_position->getArtnr()));
ui->teEditPosBezeichnung->setText(m_position->getBeschreibung());
ui->teEditPosBezeichnung->selectAll();
ui->leEditPosEinheit->setText(m_position->getEinheit());
ui->leEditPosAnzahl->setText(QString::number(m_position->getMenge()));
ui->leEditPosPreis->setText(QLocale().toCurrencyString(m_position->getPrice()).split(" ").value(0));
ui->leEditPosSumme->setText(QLocale().toCurrencyString(m_position->getTotal()).split(" ").value(0));
}
//resizeLineEditToContents
void WindowEditPosition::on_btnEditPosSave_clicked()
{
m_position->setArtnr(ui->leEditPosArtNr->text().toInt());
m_position->setBeschreibung(ui->teEditPosBezeichnung->toPlainText());
m_position->setEinheit(ui->leEditPosEinheit->text());
m_position->setMenge(ui->leEditPosAnzahl->text().toInt());
m_position->setPrice(ui->leEditPosPreis->text().replace(".", "").replace(",", ".").toDouble());
m_position->setTotal(ui->leEditPosSumme->text().replace(".", "").replace(",", ".").toDouble());
accept();
}
void WindowEditPosition::on_btnEditPosCancel_clicked()
{
reject();
}
void WindowEditPosition::on_leEditPosAnzahl_textChanged(const QString &menge)
{
double summe = menge.toInt() * ui->leEditPosPreis->text().replace(".", "").replace(",", ".").toDouble();
ui->leEditPosSumme->setText(QLocale().toCurrencyString(summe).split(" ").value(0));
}
void WindowEditPosition::on_leEditPosPreis_textChanged(const QString &preis)
{
QString preisNeu = preis;
double summe = preisNeu.replace(".", "").replace(",", ".").toDouble() * ui->leEditPosAnzahl->text().toInt();
ui->leEditPosSumme->setText(QLocale().toCurrencyString(summe).split(" ").value(0));
}
Positions *WindowEditPosition::position() const
{
return m_position;
}