src/EditProfileWater.cpp

Fri, 29 Jul 2022 13:12:26 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 29 Jul 2022 13:12:26 +0200
changeset 373
b02aca4e926c
parent 353
324a7268796b
child 385
09af9f46518f
permissions
-rw-r--r--

First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.

48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProfileWater.cpp is part of bmsapp.
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditProfileWater.h"
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditProfileWater.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: 90
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: 90
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"
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 EditProfileWater::EditProfileWater(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditProfileWater)
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 QSqlQuery query;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 qDebug() << "EditProfileWater record:" << id;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 ui->setupUi(this);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 this->recno = id;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 WindowTitle();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 if (id >= 0) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 query.prepare("SELECT * FROM profile_water WHERE record = :recno");
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 query.bindValue(":recno", id);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 query.exec();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 query.next();
ddd1171ecda5 Added profile water table and editor.
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: 90
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: 90
diff changeset
41 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: 90
diff changeset
42 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: 90
diff changeset
43 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: 90
diff changeset
44 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: 90
diff changeset
45 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: 90
diff changeset
46 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: 90
diff changeset
47 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: 90
diff changeset
48 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: 90
diff changeset
49 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: 90
diff changeset
50 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: 90
diff changeset
51 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: 90
diff changeset
52 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: 90
diff changeset
53 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: 90
diff changeset
54 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: 90
diff changeset
55 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: 90
diff changeset
56 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: 90
diff changeset
57 ui->alkalinityEdit->setValue(query.value("total_alkalinity").toDouble());
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 /* 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: 90
diff changeset
60 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: 90
diff changeset
61 sodium = magnesium = total_alkalinity = 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: 90
diff changeset
62 ph = 7.0;
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 ui->phEdit->setValue(7.0);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 }
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: 90
diff changeset
65 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: 90
diff changeset
66 ui->deleteButton->setEnabled((id >= 0) ? true:false);
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 WaterSet();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditProfileWater::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: 90
diff changeset
69 connect(ui->caEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
70 connect(ui->so4Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
71 connect(ui->clEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
72 connect(ui->naEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
73 connect(ui->mgEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
74 connect(ui->phEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::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: 90
diff changeset
75 connect(ui->alkalinityEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::total_alkalinity_changed);
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 EditProfileWater::~EditProfileWater()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 qDebug() << "EditProfileWater done";
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 delete ui;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 emit entry_changed();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 /*
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 * Window header, mark any change with '**'
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 void EditProfileWater::WindowTitle()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 QString txt;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94
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: 90
diff changeset
95 if (recno < 0) {
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 txt = QString(tr("BMSapp - Add new brewing water"));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 } 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: 90
diff changeset
98 txt = QString(tr("BMSapp - Edit brewing water %1").arg(recno));
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 if (this->textIsChanged) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 txt.append((QString(" **")));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 setWindowTitle(txt);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 void EditProfileWater::on_saveButton_clicked()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 QSqlQuery query;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 /* If there are errors in the form, show a message and do "return;" */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 if (ui->nameEdit->text().length() < 2) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 QMessageBox::warning(this, tr("Edit Water"), tr("Name empty or too short."));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 return;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 if (this->textIsChanged) {
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: 90
diff changeset
119 if (recno == -1) {
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 query.prepare("INSERT INTO profile_water SET name=:name, calcium=:ca, "
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 "total_alkalinity=:alkalinity, uuid = :uuid");
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 query.prepare("UPDATE profile_water SET name=:name, calcium=:ca, "
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 "total_alkalinity=:alkalinity WHERE record = :recno");
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 query.bindValue(":name", ui->nameEdit->text());
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: 90
diff changeset
129 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: 90
diff changeset
130 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: 90
diff changeset
131 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: 90
diff changeset
132 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: 90
diff changeset
133 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: 90
diff changeset
134 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: 90
diff changeset
135 query.bindValue(":ph", round(ph * 1000) / 1000);
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 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: 90
diff changeset
137 query.bindValue(":alkalinity", round(total_alkalinity * 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: 90
diff changeset
138 if (recno == -1) {
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 query.bindValue(":recno", this->recno);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 query.exec();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 if (query.lastError().isValid()) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 qDebug() << "EditProfileWater" << query.lastError();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 QMessageBox::warning(this, tr("Database error"),
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 tr("MySQL error: %1\n%2\n%3")
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 .arg(query.lastError().nativeErrorCode())
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 .arg(query.lastError().driverText())
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 .arg(query.lastError().databaseText()));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 qDebug() << "EditProfileWater Saved";
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 ui->saveButton->setEnabled(false);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 this->textIsChanged = false;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 WindowTitle();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 void EditProfileWater::on_deleteButton_clicked()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 QSqlQuery query;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 query.prepare("DELETE FROM profile_water WHERE record = :recno");
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 query.bindValue(":recno", this->recno);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 query.exec();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 if (query.lastError().isValid()) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 qDebug() << "EditProfileWater" << query.lastError();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 QMessageBox::warning(this, tr("Database error"),
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 tr("MySQL error: %1\n%2\n%3")
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 .arg(query.lastError().nativeErrorCode())
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 .arg(query.lastError().driverText())
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 .arg(query.lastError().databaseText()));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 qDebug() << "EditProfileWater Deleted" << this->recno;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 this->close();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 this->setResult(1);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 void EditProfileWater::WaterSet()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 {
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: 90
diff changeset
187 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: 90
diff changeset
188 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: 90
diff changeset
189 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: 90
diff changeset
190 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: 90
diff changeset
191 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: 90
diff changeset
192 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: 90
diff changeset
193 ui->hcoEdit->setValue(bicarbonate);
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194
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: 90
diff changeset
195 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: 90
diff changeset
196 double anions = (bicarbonate / MMHCO3) + (2*CO3 / MMCO3) + (2*sulfate / MMSO4) + (chloride / MMCl);
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: 90
diff changeset
197 double balance = round((cations - anions) * 100) / 100;
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 ui->balanceEdit->setValue(balance);
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: 90
diff changeset
199 ui->co3Edit->setValue(CO3);
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: 90
diff changeset
200 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: 90
diff changeset
201 ui->raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 if (balance <= 0.1 && balance >= -0.1) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png"));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 } else if (balance <= 0.5 && balance >= -0.5) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/thumb_down.png"));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 } else {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 ui->balanceIcon->setPixmap(QPixmap(":icons/silk/error.png"));
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 void EditProfileWater::is_changed()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 ui->saveButton->setEnabled(true);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 ui->deleteButton->setEnabled((this->recno >= 0) ? true:false);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 this->textIsChanged = true;
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 WindowTitle();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 void EditProfileWater::water_changed()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 WaterSet();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 is_changed();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228
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: 90
diff changeset
229 void EditProfileWater::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: 90
diff changeset
230 {
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: 90
diff changeset
231 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: 90
diff changeset
232 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: 90
diff changeset
233 }
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: 90
diff changeset
234
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: 90
diff changeset
235
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: 90
diff changeset
236 void EditProfileWater::total_alkalinity_changed(double val)
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 {
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: 90
diff changeset
238 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: 90
diff changeset
239 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: 90
diff changeset
240 }
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: 90
diff changeset
241
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: 90
diff changeset
242
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: 90
diff changeset
243 void EditProfileWater::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: 90
diff changeset
244 {
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: 90
diff changeset
245 sulfate = val;
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 water_changed();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248
ddd1171ecda5 Added profile water table and editor.
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: 90
diff changeset
250 void EditProfileWater::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: 90
diff changeset
251 {
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: 90
diff changeset
252 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: 90
diff changeset
253 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: 90
diff changeset
254 }
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: 90
diff changeset
255
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: 90
diff changeset
256
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: 90
diff changeset
257 void EditProfileWater::sodium_changed(double val)
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 {
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: 90
diff changeset
259 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: 90
diff changeset
260 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: 90
diff changeset
261 }
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: 90
diff changeset
262
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: 90
diff changeset
263
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: 90
diff changeset
264 void EditProfileWater::magnesium_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: 90
diff changeset
265 {
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: 90
diff changeset
266 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: 90
diff changeset
267 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: 90
diff changeset
268 }
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: 90
diff changeset
269
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: 90
diff changeset
270
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: 90
diff changeset
271 void EditProfileWater::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: 90
diff changeset
272 {
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: 90
diff changeset
273 ph = val;
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 water_changed();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 void EditProfileWater::on_quitButton_clicked()
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
281 int rc = QMessageBox::warning(this, tr("Water changed"), tr("This water profile has been modified. Save changes?"),
48
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 switch (rc) {
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 case QMessageBox::Save:
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 on_saveButton_clicked();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 break; /* Saved and then Quit */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 case QMessageBox::Discard:
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 break; /* Quit without Save */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 case QMessageBox::Cancel:
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 return; /* Return to the editor page */
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 }
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 this->close();
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 this->setResult(1);
ddd1171ecda5 Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 }

mercurial