Mon, 18 Jul 2022 17:04:02 +0200
Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * EditProduct.cpp is part of bmsapp. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Tab 2, equipment settings. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * bmsapp is free software: you can redistribute it and/or modify |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * the Free Software Foundation, either version 3 of the License, or |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * (at your option) any later version. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * bmsapp is distributed in the hope that it will be useful, |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * GNU General Public License for more details. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * You should have received a copy of the GNU General Public License |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | |
176
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
21 | void EditProduct::showEquipment() |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
22 | { |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
23 | ui->eq_nameEdit->setText(product->eq_name); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
24 | ui->eq_notesEdit->setPlainText(product->eq_notes); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
25 | |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
26 | /* Mashing */ |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
27 | ui->tun_volumeEdit->setValue(product->eq_tun_volume); |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
28 | ui->tun_materialEdit->setText(QCoreApplication::translate("TunMaterial", g_tun_materials[product->eq_tun_material])); |
176
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
29 | ui->mash_volumeEdit->setValue(product->eq_mash_volume); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
30 | ui->mash_maxEdit->setValue(product->eq_mash_max); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
31 | |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
32 | /* Lautering */ |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
33 | ui->lauter_volumeEdit->setValue(product->eq_lauter_volume); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
34 | ui->lauter_deadspaceEdit->setValue(product->eq_lauter_deadspace); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
35 | |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
36 | /* Boiling */ |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
37 | ui->kettle_volumeEdit->setValue(product->eq_kettle_volume); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
38 | ui->eqboil_sizeEdit->setValue(product->eq_boil_size); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
39 | ui->evap_rateEdit->setValue(product->eq_evap_rate); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
40 | ui->eqboil_timeEdit->setValue(product->eq_boil_time); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
41 | ui->topup_kettleEdit->setValue(product->eq_top_up_kettle); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
42 | ui->hop_utilizationEdit->setValue(product->eq_hop_utilization); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
43 | ui->eqbatch_sizeEdit->setValue(product->eq_batch_size); |
184
da148d6b4c95
Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
44 | ui->eq_efficiencyEdit->setValue(product->eq_efficiency); |
176
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
45 | |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
46 | /* Chilling */ |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
47 | ui->trub_chillerlossEdit->setValue(product->eq_trub_chiller_loss); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
48 | ui->topup_waterEdit->setValue(product->eq_top_up_water); |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
49 | } |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
50 | |
69a033e099a2
Tab 2 equipent, all editfields placed.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
51 | |
189 | 52 | void EditProduct::initEquipment() |
53 | { | |
54 | QSqlQuery query; | |
55 | ||
56 | ui->eq_selectEdit->addItem(""); | |
57 | query.prepare("SELECT name FROM inventory_equipments ORDER BY name"); | |
58 | query.exec(); | |
59 | while (query.next()) { | |
60 | ui->eq_selectEdit->addItem(query.value(0).toString()); | |
61 | } | |
62 | connect(ui->eq_selectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::eq_changed); | |
63 | ||
64 | showEquipment(); | |
65 | } | |
66 | ||
67 | ||
68 | void EditProduct::eq_changed(int val) | |
69 | { | |
70 | QSqlQuery query; | |
71 | ||
72 | if (val == 0) | |
73 | return; | |
74 | ||
75 | qDebug() << "equipment changed" << val; | |
76 | query.prepare("SELECT * FROM inventory_equipments ORDER BY name"); | |
77 | query.exec(); | |
78 | query.first(); | |
79 | ||
80 | for (int i; i < (val - 1); i++) { | |
81 | query.next(); | |
82 | } | |
83 | qDebug() << "got" << query.value("name").toString(); | |
84 | ||
85 | product->eq_name = query.value("name").toString(); | |
86 | product->eq_notes = query.value("notes").toString(); | |
87 | product->eq_boil_size = query.value("boil_size").toDouble(); | |
88 | product->eq_batch_size = query.value("batch_size").toDouble(); | |
89 | product->eq_tun_volume = query.value("tun_volume").toDouble(); | |
90 | product->eq_tun_weight = query.value("tun_weight").toDouble(); | |
91 | product->eq_tun_specific_heat = query.value("tun_specific_heat").toDouble(); | |
92 | product->eq_tun_material = query.value("tun_material").toInt(); | |
93 | product->eq_tun_height = query.value("tun_height").toDouble(); | |
94 | product->eq_top_up_water = query.value("top_up_water").toDouble(); | |
95 | product->eq_trub_chiller_loss = query.value("trub_chiller_loss").toDouble(); | |
96 | product->eq_evap_rate = query.value("evap_rate").toDouble(); | |
97 | product->eq_boil_time = query.value("boil_time").toDouble(); | |
98 | product->eq_calc_boil_volume = query.value("calc_boil_volume").toInt() ? true:false; | |
99 | product->eq_top_up_kettle = query.value("top_up_kettle").toDouble(); | |
100 | product->eq_hop_utilization = query.value("hop_utilization").toDouble(); | |
101 | product->eq_lauter_volume = query.value("lauter_volume").toDouble(); | |
102 | product->eq_lauter_height = query.value("lauter_height").toDouble(); | |
103 | product->eq_lauter_deadspace = query.value("lauter_deadspace").toDouble(); | |
104 | product->eq_kettle_volume = query.value("kettle_volume").toDouble(); | |
105 | product->eq_kettle_height = query.value("kettle_height").toDouble(); | |
106 | product->eq_mash_volume = query.value("mash_volume").toDouble(); | |
107 | product->eq_mash_max = query.value("mash_max").toDouble(); | |
108 | product->eq_efficiency = query.value("efficiency").toDouble(); | |
109 | showEquipment(); | |
110 | ||
111 | /* | |
112 | * Now change some important settings and recalculate the recipe parts. | |
113 | */ | |
114 | double factor = product->eq_batch_size / product->batch_size; | |
115 | double estog = product->est_og; | |
116 | ||
117 | const QSignalBlocker blocker1(ui->batch_sizeEdit); | |
118 | const QSignalBlocker blocker2(ui->boil_sizeEdit); | |
119 | const QSignalBlocker blocker3(ui->boil_timeEdit); | |
120 | const QSignalBlocker blocker4(ui->efficiencyEdit); | |
121 | ||
122 | product->boil_size = product->eq_boil_size; | |
123 | product->boil_time = product->eq_boil_time; | |
124 | product->batch_size = product->eq_batch_size; | |
125 | product->efficiency = product->eq_efficiency; | |
126 | ui->batch_sizeEdit->setValue(product->batch_size); | |
127 | ui->boil_sizeEdit->setValue(product->boil_size); | |
128 | ui->boil_timeEdit->setValue(product->boil_time); | |
129 | ui->efficiencyEdit->setValue(product->efficiency); | |
130 | ||
131 | calcFermentablesFromOG(estog); | |
132 | adjustWaters(factor); | |
133 | calcFermentables(); | |
134 | adjustHops(factor); | |
135 | adjustMiscs(factor); | |
136 | adjustYeasts(factor); | |
137 | calcIBUs(); | |
138 | calcWater(); | |
139 | calcMash(); | |
140 | is_changed(); | |
141 | emit refreshAll(); | |
142 | } | |
143 | ||
144 |