Tue, 31 Jan 2023 16:24:11 +0100
Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
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 | delete ui; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | emit entry_changed(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | } |
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 | * Window header, mark any change with '**' |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | */ |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | void EditProfileWater::WindowTitle() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | QString txt; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
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
|
94 | if (recno < 0) { |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | txt = QString(tr("BMSapp - Add new brewing water")); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | } 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
|
97 | 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
|
98 | } |
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 | if (this->textIsChanged) { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | txt.append((QString(" **"))); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | setWindowTitle(txt); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | } |
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 | void EditProfileWater::on_saveButton_clicked() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | QSqlQuery query; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | /* 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
|
112 | if (ui->nameEdit->text().length() < 2) { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | 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
|
114 | return; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | } |
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 | 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
|
118 | if (recno == -1) { |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | 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
|
120 | "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
|
121 | "total_alkalinity=:alkalinity, uuid = :uuid"); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | } else { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | 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
|
124 | "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
|
125 | "total_alkalinity=:alkalinity WHERE record = :recno"); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | query.bindValue(":ph", round(ph * 1000) / 1000); |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | 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
|
136 | 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
|
137 | if (recno == -1) { |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | } else { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | query.bindValue(":recno", this->recno); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | query.exec(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | 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
|
144 | qWarning() << "EditProfileWater" << query.lastError(); |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | QMessageBox::warning(this, tr("Database error"), |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | tr("MySQL error: %1\n%2\n%3") |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | .arg(query.lastError().nativeErrorCode()) |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | .arg(query.lastError().driverText()) |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | .arg(query.lastError().databaseText())); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | } else { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | qDebug() << "EditProfileWater Saved"; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | } |
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 | ui->saveButton->setEnabled(false); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | this->textIsChanged = false; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | WindowTitle(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } |
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 | |
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
|
161 | void EditProfileWater::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
|
162 | { |
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
|
163 | 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
|
164 | |
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
|
165 | query.prepare("INSERT INTO profile_water SET name=:name, 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
|
166 | "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
|
167 | "total_alkalinity=:alkalinity, 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
|
168 | |
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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | |
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 | 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
|
182 | 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
|
183 | qWarning() << "EditProfileWater" << 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
|
184 | 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
|
185 | 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
|
186 | .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
|
187 | .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
|
188 | .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
|
189 | } 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
|
190 | qDebug() << "EditProfileWater 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
|
191 | } |
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 | } |
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 | |
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 | |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | void EditProfileWater::on_deleteButton_clicked() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | QSqlQuery query; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | |
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
|
199 | int rc = QMessageBox::warning(this, tr("Delete water profile"), 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
|
200 | 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
|
201 | 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
|
202 | 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
|
203 | |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | query.prepare("DELETE FROM profile_water WHERE record = :recno"); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | query.bindValue(":recno", this->recno); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | query.exec(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | 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
|
208 | qWarning() << "EditProfileWater" << query.lastError(); |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | QMessageBox::warning(this, tr("Database error"), |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | tr("MySQL error: %1\n%2\n%3") |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | .arg(query.lastError().nativeErrorCode()) |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | .arg(query.lastError().driverText()) |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | .arg(query.lastError().databaseText())); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | } else { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | qDebug() << "EditProfileWater Deleted" << this->recno; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | this->close(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | this->setResult(1); |
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 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | void EditProfileWater::WaterSet() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | { |
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
|
225 | 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
|
226 | 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
|
227 | 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
|
228 | 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
|
229 | 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
|
230 | 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
|
231 | ui->hcoEdit->setValue(bicarbonate); |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | |
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
|
233 | 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
|
234 | 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
|
235 | double balance = round((cations - anions) * 100) / 100; |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | 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
|
237 | 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
|
238 | 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
|
239 | 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
|
240 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | if (balance <= 0.1 && balance >= -0.1) { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png")); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | } else if (balance <= 0.5 && balance >= -0.5) { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | ui->balanceIcon->setPixmap(QPixmap(":icons/silk/thumb_down.png")); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | } else { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
246 | ui->balanceIcon->setPixmap(QPixmap(":icons/silk/error.png")); |
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 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
250 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
251 | void EditProfileWater::is_changed() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
252 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
253 | ui->saveButton->setEnabled(true); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
254 | ui->deleteButton->setEnabled((this->recno >= 0) ? true:false); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | this->textIsChanged = true; |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
256 | WindowTitle(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
257 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
258 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
260 | void EditProfileWater::water_changed() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
261 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
262 | WaterSet(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
263 | is_changed(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
266 | |
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
|
267 | 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
|
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 | 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
|
270 | 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
|
271 | } |
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 | |
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
|
274 | void EditProfileWater::total_alkalinity_changed(double val) |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | { |
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
|
276 | 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
|
277 | 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
|
278 | } |
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
|
279 | |
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
|
280 | |
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
|
281 | 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
|
282 | { |
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
|
283 | sulfate = val; |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
284 | water_changed(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
285 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | |
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
|
288 | 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
|
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:
90
diff
changeset
|
290 | 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
|
291 | 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
|
292 | } |
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
|
293 | |
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
|
294 | |
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
|
295 | void EditProfileWater::sodium_changed(double val) |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
296 | { |
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
|
297 | 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
|
298 | 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
|
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:
90
diff
changeset
|
300 | |
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
|
301 | |
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
|
302 | 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
|
303 | { |
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
|
304 | 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
|
305 | 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
|
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:
90
diff
changeset
|
307 | |
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
|
308 | |
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
|
309 | 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
|
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:
90
diff
changeset
|
311 | ph = val; |
48
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | water_changed(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
313 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
316 | void EditProfileWater::on_quitButton_clicked() |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
317 | { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | if (this->textIsChanged) { |
60
0d65238ebedc
Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
319 | 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
|
320 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
321 | switch (rc) { |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
322 | case QMessageBox::Save: |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | on_saveButton_clicked(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | break; /* Saved and then Quit */ |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | case QMessageBox::Discard: |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
326 | break; /* Quit without Save */ |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
327 | case QMessageBox::Cancel: |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
328 | return; /* Return to the editor page */ |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
329 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
330 | } |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
332 | this->close(); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | this->setResult(1); |
ddd1171ecda5
Added profile water table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | } |