src/EditWater.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 385
09af9f46518f
permissions
-rw-r--r--

Init est_carb field for new products.

29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditWater.cpp is part of bmsapp.
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditWater.h"
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditWater.h"
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
19 #include "global.h"
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
20 #include "Utils.h"
90
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
21 #include "MainWindow.h"
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 EditWater::EditWater(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditWater)
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 QSqlQuery query;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 qDebug() << "EditWater record:" << id;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 ui->setupUi(this);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 this->recno = id;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 WindowTitle();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 if (id >= 0) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 query.prepare("SELECT * FROM inventory_waters WHERE record = :recno");
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 query.bindValue(":recno", id);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 query.exec();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 query.next();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
40 ui->nameEdit->setText(query.value("name").toString());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
41 ui->unlimitedEdit->setChecked(query.value("unlimited_stock").toInt() ? true:false);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
42 calcium = query.value("calcium").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
43 ui->caEdit->setValue(query.value("calcium").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
44 bicarbonate = query.value("bicarbonate").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
45 ui->hcoEdit->setValue(query.value("bicarbonate").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
46 sulfate = query.value("sulfate").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
47 ui->so4Edit->setValue(query.value("sulfate").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
48 chloride = query.value("chloride").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
49 ui->clEdit->setValue(query.value("chloride").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
50 sodium = query.value("sodium").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
51 ui->naEdit->setValue(query.value("sodium").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
52 magnesium = query.value("magnesium").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
53 ui->mgEdit->setValue(query.value("magnesium").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
54 ph = query.value("ph").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
55 ui->phEdit->setValue(query.value("ph").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
56 ui->notesEdit->setPlainText(query.value("notes").toString());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
57 total_alkalinity = query.value("total_alkalinity").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
58 ui->alkalinityEdit->setValue(query.value("total_alkalinity").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
59 ui->inventoryEdit->setValue(query.value("inventory").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
60 ui->costEdit->setValue(query.value("cost").toDouble());
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
61 nitrate = query.value("nitrate").toDouble();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
62 ui->noEdit->setValue(query.value("nitrate").toDouble());
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 } else {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 /* Set some defaults */
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
65 calcium = bicarbonate = sulfate = chloride = 0;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
66 sodium = magnesium = total_alkalinity = nitrate = 0;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
67 ph = 7.0;
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 ui->phEdit->setValue(7.0);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 }
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
70 ui->saveButton->setEnabled(false);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
71 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 WaterSet();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditWater::is_changed);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 connect(ui->unlimitedEdit, &QCheckBox::stateChanged, this, &EditWater::is_changed);
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
75 connect(ui->caEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::calcium_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
76 connect(ui->so4Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::sulfate_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
77 connect(ui->clEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::chloride_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
78 connect(ui->naEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::sodium_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
79 connect(ui->mgEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::magnesium_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
80 connect(ui->phEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::ph_changed);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
81 connect(ui->alkalinityEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::total_alkalinity_changed);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditWater::is_changed);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditWater::is_changed);
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
85 connect(ui->noEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::nitrate_changed);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 EditWater::~EditWater()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 delete ui;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 emit entry_changed();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 /*
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 * Window header, mark any change with '**'
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 void EditWater::WindowTitle()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 QString txt;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
103 if (recno < 0) {
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 txt = QString(tr("BMSapp - Add new brewing water"));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 } else {
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
106 txt = QString(tr("BMSapp - Edit brewing water %1").arg(recno));
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 if (this->textIsChanged) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 txt.append((QString(" **")));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 setWindowTitle(txt);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 void EditWater::on_saveButton_clicked()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 QSqlQuery query;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 /* If there are errors in the form, show a message and do "return;" */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 if (ui->nameEdit->text().length() < 2) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 QMessageBox::warning(this, tr("Edit Water"), tr("Name empty or too short."));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 return;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 if (this->textIsChanged) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 if (this->recno == -1) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 query.prepare("INSERT INTO inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, "
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
236
d0b1640ba951 Added inverntory waters nitrate column. Added nitrate and carbonate in the water edit screen.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
130 "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, nitrate=:no, uuid = :uuid");
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 } else {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 query.prepare("UPDATE inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, "
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
236
d0b1640ba951 Added inverntory waters nitrate column. Added nitrate and carbonate in the water edit screen.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
134 "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, nitrate=:no WHERE record = :recno");
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 query.bindValue(":name", ui->nameEdit->text());
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 query.bindValue(":unlimited", ui->unlimitedEdit->isChecked() ? 1:0);
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
138 query.bindValue(":ca", round(calcium * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
139 query.bindValue(":hco", round(bicarbonate * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
140 query.bindValue(":so4", round(sulfate * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
141 query.bindValue(":cl", round(chloride * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
142 query.bindValue(":na", round(sodium * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
143 query.bindValue(":mg", round(magnesium * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
144 query.bindValue(":ph", round(ph * 1000) / 1000);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 query.bindValue(":notes", ui->notesEdit->toPlainText());
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
146 query.bindValue(":alkalinity", round(total_alkalinity * 1000) / 1000);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value(), 2, 'f', 1, '0'));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 6, 'f', 5, '0'));
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
149 query.bindValue(":no", round(nitrate * 1000) / 1000);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
150 if (recno == -1) {
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 } else {
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
153 query.bindValue(":recno", recno);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 query.exec();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
157 qWarning() << "EditWater" << query.lastError();
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 QMessageBox::warning(this, tr("Database error"),
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 tr("MySQL error: %1\n%2\n%3")
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 .arg(query.lastError().nativeErrorCode())
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 .arg(query.lastError().driverText())
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 .arg(query.lastError().databaseText()));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 } else {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 qDebug() << "EditWater Saved";
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 ui->saveButton->setEnabled(false);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 this->textIsChanged = false;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 WindowTitle();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
174 void EditWater::on_cloneButton_clicked()
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
175 {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
176 QSqlQuery query;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
177
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
178 query.prepare("INSERT INTO inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, "
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
179 "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
180 "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, nitrate=:no, uuid = :uuid");
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
181
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
182 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
183 query.bindValue(":unlimited", ui->unlimitedEdit->isChecked() ? 1:0);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
184 query.bindValue(":ca", round(calcium * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
185 query.bindValue(":hco", round(bicarbonate * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
186 query.bindValue(":so4", round(sulfate * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
187 query.bindValue(":cl", round(chloride * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
188 query.bindValue(":na", round(sodium * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
189 query.bindValue(":mg", round(magnesium * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
190 query.bindValue(":ph", round(ph * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
191 query.bindValue(":notes", ui->notesEdit->toPlainText());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
192 query.bindValue(":alkalinity", round(total_alkalinity * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
193 query.bindValue(":inventory", QString("%1").arg(0, 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
194 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 6, 'f', 5, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
195 query.bindValue(":no", round(nitrate * 1000) / 1000);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
196 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
197
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
198 query.exec();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
199 if (query.lastError().isValid()) {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
200 qWarning() << "EditWater" << query.lastError();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
201 QMessageBox::warning(this, tr("Database error"),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
202 tr("MySQL error: %1\n%2\n%3")
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
203 .arg(query.lastError().nativeErrorCode())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
204 .arg(query.lastError().driverText())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
205 .arg(query.lastError().databaseText()));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
206 } else {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
207 qDebug() << "EditWater Saved";
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
208 }
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
209 }
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
210
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
211
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 void EditWater::on_deleteButton_clicked()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 QSqlQuery query;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
216 int rc = QMessageBox::warning(this, tr("Delete water"), tr("Delete %1").arg(ui->nameEdit->text()),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
217 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
218 if (rc == QMessageBox::No)
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
219 return;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
220
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 query.prepare("DELETE FROM inventory_waters WHERE record = :recno");
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 query.bindValue(":recno", this->recno);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 query.exec();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 353
diff changeset
225 qWarning() << "EditWater" << query.lastError();
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 QMessageBox::warning(this, tr("Database error"),
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 tr("MySQL error: %1\n%2\n%3")
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 .arg(query.lastError().nativeErrorCode())
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 .arg(query.lastError().driverText())
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 .arg(query.lastError().databaseText()));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 } else {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 qDebug() << "EditWater Deleted" << this->recno;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 this->close();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 this->setResult(1);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 void EditWater::WaterSet()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 {
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
242 double CO3 = total_alkalinity * pow(10, ph - 10.33) / (1+2* pow(10, ph - 10.33)) * MMCO3 / (MMCaCO3 / 2);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
243 double t_bicarbonate = Utils::Bicarbonate(total_alkalinity, ph);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
244 qDebug() << t_bicarbonate << bicarbonate;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
245 if ((round(t_bicarbonate * 1000) / 1000) != bicarbonate)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
246 is_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
247 bicarbonate = t_bicarbonate;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
248 ui->hcoEdit->setValue(bicarbonate);
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
250 double cations = (2*calcium / MMCa) + (2*magnesium / MMMg) + (sodium / MMNa);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
251 double anions = (bicarbonate / MMHCO3) + (2*CO3 / MMCO3) + (2*sulfate / MMSO4) + (chloride / MMCl) + (nitrate / MMNO3);
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
252 double balance = round((cations - anions) * 100) / 100;
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 ui->balanceEdit->setValue(balance);
236
d0b1640ba951 Added inverntory waters nitrate column. Added nitrate and carbonate in the water edit screen.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
254 ui->co3Edit->setValue(CO3);
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
255 ui->hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
256 ui->raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 if (balance <= 0.1 && balance >= -0.1) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png"));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 } else if (balance <= 0.5 && balance >= -0.5) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/thumb_down.png"));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 } else {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/error.png"));
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 void EditWater::is_changed()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 ui->saveButton->setEnabled(true);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 this->textIsChanged = true;
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 WindowTitle();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 void EditWater::water_changed()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 WaterSet();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 is_changed();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
284 void EditWater::calcium_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
285 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
286 calcium = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
287 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
288 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
289
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
290
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
291 void EditWater::total_alkalinity_changed(double val)
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 {
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
293 total_alkalinity = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
294 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
295 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
296
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
297
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
298 void EditWater::sulfate_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
299 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
300 sulfate = val;
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 water_changed();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
305 void EditWater::chloride_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
306 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
307 chloride = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
308 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
309 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
310
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
311
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
312 void EditWater::sodium_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
313 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
314 sodium = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
315 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
316 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
317
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
318
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
319 void EditWater::magnesium_changed(double val)
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 {
353
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
321 magnesium = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
322 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
323 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
324
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
325
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
326 void EditWater::ph_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
327 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
328 ph = val;
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
329 water_changed();
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
330 }
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
331
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
332
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
333 void EditWater::nitrate_changed(double val)
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
334 {
324a7268796b Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.
Michiel Broek <mbroek@mbse.eu>
parents: 236
diff changeset
335 nitrate = val;
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 water_changed();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 void EditWater::on_quitButton_clicked()
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
343 int rc = QMessageBox::warning(this, tr("Water changed"), tr("The brewing water has been modified. Save changes?"),
29
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 switch (rc) {
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 case QMessageBox::Save:
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 on_saveButton_clicked();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 break; /* Saved and then Quit */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 case QMessageBox::Discard:
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 break; /* Quit without Save */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 case QMessageBox::Cancel:
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 return; /* Return to the editor page */
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 }
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 this->close();
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 this->setResult(1);
76846c99f827 Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 }

mercurial