Sat, 14 Oct 2023 11:23:24 +0200
Load and show current calibration data.
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 11, package |
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 | |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
20 | |
439
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
21 | double EditProduct::GetPressure(double CO2, double T) |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
22 | { |
439
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
23 | if (CO2 < 0) |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
24 | return 0; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
25 | |
439
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
26 | double P = -1.09145427669121 + 0.00800006989646477 * T + 0.000260276315484684 * T * T + 0.0215142075945119 * T * CO2 + |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
27 | 0.674996600795854 * CO2 + -0.00471757220150754 * CO2 * CO2; |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
28 | |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
29 | P = round((P * 1.01325) * 100.0) / 100.0; // atm to bar |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
30 | qDebug() << " GetPressure(" << CO2 << "," << T << ") CO2:" << CO2 << "Bar:" << P; |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
31 | return P; |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
32 | } |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
33 | |
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
34 | |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
35 | double EditProduct::CarbCO2ToPressure(double CO2, double T) |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
36 | { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
37 | return (CO2 - (-0.000005594056 * pow(T, 4) + 0.000144357886 * pow(T, 3) + |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
38 | 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) / |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
39 | (0.00000498031 * pow(T, 4) - 0.00024358267 * pow(T, 3) + 0.00385867329 * T * T - 0.05671206825 * T + 1.53801423376); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
40 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
41 | |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
43 | void EditProduct::calcPack() |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
44 | { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
45 | int i, j; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
46 | bool found1, found2; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
47 | QSqlQuery query; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
48 | double TSec, SFactor; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
49 | |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
50 | qDebug() << "calcPack()" << product->package_volume << product->package_abv << "inf" << product->package_infuse_amount << product->package_infuse_abv; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
51 | |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
52 | if (product->package_volume < 1) { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
53 | /* |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
54 | * If there is not enough to package, then don't |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
55 | * do any calculations and clear the rest of the form. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
56 | */ |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
57 | product->package_volume = 0; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
58 | ui->pack_finalabvShow->setValue(0); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
59 | |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
60 | return; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
61 | } |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
62 | |
448
9e0da3824cf9
Make sure the package abv is final when the tertiary fermentation data is filled in.
Michiel Broek <mbroek@mbse.eu>
parents:
447
diff
changeset
|
63 | if ((product->stage >= PROD_STAGE_TERTIARY) && (product->fg >= 0.990)) { |
9e0da3824cf9
Make sure the package abv is final when the tertiary fermentation data is filled in.
Michiel Broek <mbroek@mbse.eu>
parents:
447
diff
changeset
|
64 | /* Make sure we have the final value. */ |
9e0da3824cf9
Make sure the package abv is final when the tertiary fermentation data is filled in.
Michiel Broek <mbroek@mbse.eu>
parents:
447
diff
changeset
|
65 | product->package_abv = Utils::abvol(product->brew_fermenter_sg, product->fg); |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
66 | ui->pack_abvLabel->setText(tr("Package ABV %:")); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
67 | ui->pack_finalabvLabel->setText(tr("Final ABV %:")); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
68 | ui->pack_finalibuLabel->setText(tr("Final IBU:")); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
69 | } else { |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
70 | product->package_abv = product->est_abv; |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
71 | } |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
72 | |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
73 | double bvol = product->package_volume - (product->package_abv * product->package_volume) / 100.0; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
74 | double balc = product->package_volume - bvol; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
75 | double mvol = product->package_infuse_amount - (product->package_infuse_abv * product->package_infuse_amount) / 100.0; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
76 | double malc = product->package_infuse_amount - mvol; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
77 | double talc = balc + malc; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
78 | double tvol = bvol + mvol; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
79 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
80 | product->final_abv = round(talc / (tvol + talc) * 10000.0) / 100.0; |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
81 | ui->pack_abvShow->setValue(product->package_abv); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
82 | ui->pack_finalabvShow->setValue(product->final_abv); |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
83 | |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
84 | double pack_color = product->brew_fermenter_color * (product->package_volume / (product->package_volume + product->package_infuse_amount)); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
85 | double pack_ibu = product->brew_fermenter_ibu * (product->package_volume / (product->package_volume + product->package_infuse_amount)); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
86 | |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
87 | ui->pack_finalcolorShow->setValue(pack_color); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
88 | ui->pack_finalcolorShow->setStyleSheet(Utils::ebc_to_style(pack_color)); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
89 | ui->pack_finalibuShow->setValue(pack_ibu); |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
90 | |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
91 | TSec = product->secondary_temp; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
92 | if (TSec < 1) |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
93 | TSec = product->primary_end_temp; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
94 | if (TSec < 1) |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
95 | TSec = 18; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
96 | |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
97 | /* |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
98 | * For bottles and kegs use the following complicated procedure to |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
99 | * find the needed priming sugars. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
100 | * |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
101 | * 1. If we need a priming sugar then first see in the fermentables |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
102 | * table if there is one selected. If not, clear sugars and done. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
103 | * 2. Then, we update the data from the fermentables inventory. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
104 | * 3. Set the found sugar in the pulldown menu. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
105 | * 4. Calculate the sugar in gr/L and total amount need. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
106 | * 5. Calculate the ABV in the bottles/kegs. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
107 | * 6. Calculate the pressure build by the refermentation. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
108 | * |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
109 | * Note that this is all a leftover from the web based application that |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
110 | * did work like this. It's a bit strange but it will allways give |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
111 | * the right data and sugar concentrations. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
112 | * Sometimes bugs have good things. |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
113 | */ |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
114 | found1 = false; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
115 | if (product->bottle_amount) { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
116 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
117 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
118 | found1 = true; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
119 | break; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
120 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
121 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
122 | if (found1) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
123 | SFactor = 1 / ((product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
124 | qDebug() << " bottle sugar" << product->fermentables.at(i).name << SFactor << TSec; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
125 | |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
126 | query.prepare("SELECT name,supplier FROM inventory_fermentables WHERE type = '1' OR type = '3' ORDER BY name"); // Sugars or dry extract |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
127 | query.exec(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
128 | j = 0; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
129 | found2 = false; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
130 | while (query.next()) { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
131 | j++; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
132 | if (query.value(0).toString() == product->fermentables.at(i).name && query.value(1).toString() == product->fermentables.at(i).supplier) { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
133 | ui->bottle_sugarEdit->setCurrentIndex(j); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
134 | product->bottle_priming_sugar = j; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
135 | found2 = true; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
136 | break; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
137 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
138 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
139 | if (! found2) { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
140 | ui->bottle_sugarEdit->setCurrentIndex(0); // Make sure not selected |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
141 | product->fermentables.removeAt(i); // Remove false fermentable |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
142 | refreshFermentables(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
143 | } else { |
443
3c195eb4e7a1
Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
144 | product->bottle_priming_amount = Utils::CarbCO2toS(product->bottle_carbonation, TSec, SFactor); |
3c195eb4e7a1
Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
145 | //qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
146 | ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
147 | double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
148 | if (total != product->fermentables.at(i).amount) { |
439
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
149 | qDebug() << " total" << total << product->fermentables.at(i).amount; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
150 | qDebug() << " update priming sugar" << total; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
151 | product->fermentables[i].amount = total; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
152 | refreshFermentables(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
153 | is_changed(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
154 | } |
224
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
155 | ui->bottle_sug_weightShow->setValue(total * 1000); |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
156 | |
222
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
157 | double pabv = product->final_abv + (product->bottle_priming_amount * (1 / SFactor) * 0.47) / 7.907; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
158 | double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
159 | talc = product->bottle_amount - pvol; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
160 | tvol = pvol + product->bottle_priming_water; |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
161 | product->bottle_abv = talc / (tvol + talc) * 100; |
443
3c195eb4e7a1
Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
162 | product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount * (1 / SFactor), product->bottle_carbonation_temp); |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
163 | ui->bottle_abvShow->setValue(product->bottle_abv); |
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
164 | ui->bottle_barShow->setValue(product->bottle_bar); |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
165 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
166 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
167 | } |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
168 | if (! found1) { |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
169 | qDebug() << " no bottle priming"; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
170 | ui->bottle_sug_amountShow->setValue(0); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
171 | ui->bottle_sug_weightShow->setValue(0); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
172 | ui->bottle_abvShow->setValue(0); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
173 | ui->bottle_barShow->setValue(0); |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
174 | product->bottle_abv = 0; |
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
175 | product->bottle_bar = 0; |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
176 | } |
397
877420a13815
Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents:
332
diff
changeset
|
177 | ui->est_bottle_co2Edit->setValue(product->bottle_carbonation); |
877420a13815
Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents:
332
diff
changeset
|
178 | ui->est_bottle_co2Show->setValue(product->bottle_carbonation); |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
179 | |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
180 | ui->keg_sugarLabel->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
181 | ui->keg_sugarEdit->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
182 | ui->keg_sug_weightLabel->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
183 | ui->keg_sug_weightShow->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
184 | ui->keg_sug_waterLabel->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
185 | ui->keg_sug_waterEdit->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
186 | ui->keg_sug_amountLabel->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
187 | ui->keg_sug_amountShow->setEnabled(! product->keg_forced_carb); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
188 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
189 | found1 = false; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
190 | if (product->keg_amount) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
191 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
192 | double Pressure = CarbCO2ToPressure(product->keg_carbonation, product->keg_carbonation_temp); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
193 | if (Pressure < 0) |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
194 | Pressure = 0; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
195 | product->keg_pressure = Pressure; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
196 | ui->keg_barShow->setValue(Pressure); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
197 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
198 | if (! product->keg_forced_carb) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
199 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
200 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS) { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
201 | found1 = true; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
202 | break; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
203 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
204 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
205 | if (found1) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
206 | SFactor = 1 / ((product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
207 | qDebug() << " kegs sugar" << product->fermentables.at(i).name << SFactor << TSec; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
208 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
209 | query.prepare("SELECT name,supplier FROM inventory_fermentables WHERE type = '1' OR type = '3' ORDER BY name"); // Sugars or dry extract |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
210 | query.exec(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
211 | j = 0; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
212 | found2 = false; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
213 | while (query.next()) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
214 | j++; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
215 | if (query.value(0).toString() == product->fermentables.at(i).name && query.value(1).toString() == product->fermentables.at(i).supplier) { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
216 | ui->keg_sugarEdit->setCurrentIndex(j); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
217 | product->keg_priming_sugar = j; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
218 | found2 = true; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
219 | break; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
220 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
221 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
222 | if (! found2) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
223 | ui->keg_sugarEdit->setCurrentIndex(0); // Make sure not selected |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
224 | product->fermentables.removeAt(i); // Remove false fermentable |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
225 | refreshFermentables(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
226 | } else { |
443
3c195eb4e7a1
Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
227 | product->keg_priming_amount = Utils::CarbCO2toS(product->keg_carbonation, TSec, SFactor); |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
228 | ui->keg_sug_amountShow->setValue(product->keg_priming_amount); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
229 | double total = round(product->keg_priming_amount * product->keg_amount * 100.0) / 100000.0; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
230 | qDebug() << " total" << total << product->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
231 | if (total != product->fermentables.at(i).amount) { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
232 | qDebug() << " update priming sugar" << total; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
233 | product->fermentables[i].amount = total; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
234 | refreshFermentables(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
235 | is_changed(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
236 | } |
224
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
237 | ui->keg_sug_weightShow->setValue(total * 1000); |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
238 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
239 | double pabv = product->final_abv + (product->keg_priming_amount * (1 / SFactor) * 0.47) / 7.907; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
240 | double pvol = product->keg_amount - (pabv * product->keg_amount) / 100; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
241 | talc = product->keg_amount - pvol; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
242 | tvol = pvol + product->keg_priming_water; |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
243 | product->keg_abv = talc / (tvol + talc) * 100; |
439
31419b7cee69
Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents:
427
diff
changeset
|
244 | product->keg_bar = GetPressure(product->keg_carbonation, product->keg_carbonation_temp); |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
245 | ui->keg_abvShow->setValue(product->keg_abv); |
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
246 | ui->keg_barShow->setValue(product->keg_bar); |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
247 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
248 | } // if priming sugar. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
249 | if (! found1) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
250 | qDebug() << " no keg priming"; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
251 | ui->keg_sug_amountShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
252 | ui->keg_sug_weightShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
253 | ui->keg_abvShow->setValue(0); |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
254 | product->keg_abv = 0; |
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
255 | product->keg_bar = 0; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
256 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
257 | } else { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
258 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
259 | * Forced carbonation |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
260 | */ |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
261 | ui->keg_abvShow->setValue(product->final_abv); |
238
047e99c90848
Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module.
Michiel Broek <mbroek@mbse.eu>
parents:
224
diff
changeset
|
262 | product->keg_abv = product->final_abv; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
263 | ui->keg_sug_amountShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
264 | ui->keg_sug_weightShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
265 | } |
397
877420a13815
Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents:
332
diff
changeset
|
266 | ui->est_kegs_co2Edit->setValue(product->keg_carbonation); |
877420a13815
Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents:
332
diff
changeset
|
267 | ui->est_kegs_co2Show->setValue(product->keg_carbonation); |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
268 | } // if keg_amount |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
269 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
270 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
271 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
272 | /* |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
273 | * Triggered by writing to ui->pack_abvShow |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
274 | */ |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
275 | void EditProduct::pack_abv_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
276 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
277 | calcPack(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
278 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
279 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
280 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
281 | void EditProduct::pack_date_changed(QDate val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
282 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
283 | qDebug() << "pack_date_changed" << val; |
224
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
284 | product->package_date = ui->pack_dateEdit->nullDate(); |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
285 | is_changed(); |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
286 | setStage(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
287 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
288 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
289 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
290 | void EditProduct::pack_date_button() |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
291 | { |
224
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
292 | ui->pack_dateEdit->setDate(QDate::currentDate()); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
293 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
294 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
295 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
296 | void EditProduct::pack_date_ack() |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
297 | { |
224
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
298 | int rc = QMessageBox::warning(this, tr("Confirm package"), tr("Confirm that the beer is packaged and all data is correct"), |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
299 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
300 | |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
301 | if (rc == QMessageBox::No) |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
302 | return; |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
303 | |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
304 | product->stage = PROD_STAGE_CARBONATION; |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
305 | setStage(); |
d369948a3eb5
Added stage changing from tertiary fermentation upto carbonation. Show, hide, readonly etc for the package tab. Make sure current sugar amounts are displayed. Added package date and buttons.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
306 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
307 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
308 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
309 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
310 | void EditProduct::pack_volume_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
311 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
312 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
313 | * If the total volume is decreased, check if the |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
314 | * bottle and kegs amount need to be lowered as well. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
315 | */ |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
316 | |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
317 | product->package_volume = val; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
318 | calcPack(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
319 | is_changed(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
320 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
321 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
322 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
323 | void EditProduct::pack_ph_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
324 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
325 | if (product->package_ph == 0) { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
326 | product->package_ph = 4.0; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
327 | const QSignalBlocker blocker1(ui->pack_phEdit); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
328 | ui->pack_phEdit->setValue(4.0); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
329 | } else { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
330 | product->package_ph = val; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
331 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
332 | is_changed(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
333 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
334 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
335 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
336 | void EditProduct::pack_infusion_vol_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
337 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
338 | product->package_infuse_amount = val; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
339 | calcPack(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
340 | is_changed(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
341 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
342 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
343 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
344 | void EditProduct::pack_infusion_abv_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
345 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
346 | product->package_infuse_abv = val; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
347 | calcPack(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
348 | is_changed(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
349 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
350 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
351 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
352 | void EditProduct::pack_infusion_txt_changed(QString val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
353 | { |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
354 | product->package_infuse_notes = val; |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
355 | is_changed(); |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
356 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
357 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
358 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
359 | void EditProduct::bottle_volume_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
360 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
361 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
362 | * Check if kegs volume plus this new volume fits in the package volume. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
363 | */ |
404
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
364 | const QSignalBlocker blocker1(ui->keg_volumeEdit); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
365 | if (product->keg_amount < 0) |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
366 | product->keg_amount = 0; /* Failsafe - bugfix */ |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
367 | if (val > (product->package_volume + product->package_infuse_amount)) { |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
368 | val = product->package_volume + product->package_infuse_amount; |
404
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
369 | const QSignalBlocker blocker2(ui->bottle_volumeEdit); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
370 | ui->bottle_volumeEdit->setValue(val); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
371 | } |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
372 | |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
373 | if ((val + product->keg_amount) > (product->package_volume + product->package_infuse_amount)) { |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
374 | double kegs = product->package_volume + product->package_infuse_amount - val; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
375 | product->keg_amount = kegs; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
376 | ui->keg_volumeEdit->setValue(kegs); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
377 | } |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
378 | product->bottle_amount = val; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
379 | calcPack(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
380 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
381 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
382 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
383 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
384 | void EditProduct::bottle_co2_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
385 | { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
386 | product->bottle_carbonation = val; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
387 | calcPack(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
388 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
389 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
390 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
391 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
392 | void EditProduct::bottle_sugar_changed(int val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
393 | { |
222
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
394 | Fermentables newf; |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
395 | QSqlQuery query; |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
396 | |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
397 | qDebug() << "bottle_sugar_changed" << product->bottle_priming_sugar << val; |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
398 | for (int i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
399 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) { |
222
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
400 | product->fermentables.removeAt(i); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
401 | refreshFermentables(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
402 | break; |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
403 | } |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
404 | } |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
405 | |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
406 | /* |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
407 | * Search the sugar pointed by the index. |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
408 | */ |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
409 | QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch," |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
410 | "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57,inventory FROM inventory_fermentables " |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
411 | "WHERE type = '1' OR type = '3' ORDER BY name"; |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
412 | query.prepare(sql); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
413 | query.exec(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
414 | query.first(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
415 | for (int i = 0; i < (val - 1); i++) { |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
416 | query.next(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
417 | } |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
418 | |
427
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
419 | newf.name = query.value("name").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
420 | newf.origin = query.value("origin").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
421 | newf.supplier = query.value("supplier").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
422 | newf.cost = query.value("cost").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
423 | newf.type = query.value("type").toInt(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
424 | newf.yield = query.value("yield").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
425 | newf.color = query.value("color").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
426 | newf.coarse_fine_diff = query.value("coarse_fine_diff").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
427 | newf.moisture = query.value("moisture").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
428 | newf.diastatic_power = query.value("diastatic_power").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
429 | newf.protein = query.value("protein").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
430 | newf.dissolved_protein = query.value("dissolved_protein").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
431 | newf.max_in_batch = query.value("max_in_batch").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
432 | newf.graintype = query.value("graintype").toInt(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
433 | newf.recommend_mash = query.value("recommend_mash").toInt() ? true:false; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
434 | newf.add_after_boil = true; |
427
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
435 | newf.di_ph = query.value("di_ph").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
436 | newf.acid_to_ph_57 = query.value("acid_to_ph_57").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
437 | newf.inventory = query.value("inventory").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
438 | newf.adjust_to_total_100 = false; |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
439 | newf.percentage = 0; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
440 | newf.amount = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
441 | newf.added = FERMENTABLE_ADDED_BOTTLE; |
222
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
442 | |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
443 | product->fermentables.append(newf); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
444 | refreshFermentables(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
445 | const QSignalBlocker blocker1(ui->bottle_sugarEdit); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
446 | calcPack(); |
c5a3beb15eef
Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
447 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
448 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
449 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
450 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
451 | void EditProduct::bottle_water_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
452 | { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
453 | product->bottle_priming_water = val; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
454 | calcPack(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
455 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
456 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
457 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
458 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
459 | void EditProduct::bottle_temp_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
460 | { |
221
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
461 | product->bottle_carbonation_temp = val; |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
462 | calcPack(); |
54828816233f
Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
463 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
464 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
465 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
466 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
467 | void EditProduct::kegs_volume_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
468 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
469 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
470 | * Check if bottle volume plus this new volume fits in the package volume. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
471 | */ |
404
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
472 | const QSignalBlocker blocker1(ui->bottle_volumeEdit); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
473 | if (product->bottle_amount < 0) |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
474 | product->bottle_amount = 0; /* Failsafe - bugfix */ |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
475 | if (val > (product->package_volume + product->package_infuse_amount)) { |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
476 | val = product->package_volume + product->package_infuse_amount; |
404
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
477 | const QSignalBlocker blocker2(ui->keg_volumeEdit); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
478 | ui->keg_volumeEdit->setValue(val); |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
479 | } |
47f1259378fe
Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
480 | |
447
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
481 | if ((val + product->bottle_amount) > (product->package_volume + product->package_infuse_amount)) { |
9b5acb1f5776
Added show package color and ibu and take dillution in account
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
482 | double bottle = product->package_volume + product->package_infuse_amount - val; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
483 | product->bottle_amount = bottle; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
484 | ui->bottle_volumeEdit->setValue(bottle); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
485 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
486 | product->keg_amount = val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
487 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
488 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
489 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
490 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
491 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
492 | void EditProduct::kegs_co2_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
493 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
494 | product->keg_carbonation = val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
495 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
496 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
497 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
498 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
499 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
500 | void EditProduct::kegs_sugar_changed(int val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
501 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
502 | Fermentables newf; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
503 | QSqlQuery query; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
504 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
505 | qDebug() << "kegs_sugar_changed" << product->keg_priming_sugar << val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
506 | for (int i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
507 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS) { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
508 | product->fermentables.removeAt(i); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
509 | refreshFermentables(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
510 | break; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
511 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
512 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
513 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
514 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
515 | * Search the sugar pointed by the index. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
516 | */ |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
517 | QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch," |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
518 | "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57,inventory FROM inventory_fermentables " |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
519 | "WHERE type = '1' OR type = '3' ORDER BY name"; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
520 | query.prepare(sql); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
521 | query.exec(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
522 | query.first(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
523 | for (int i = 0; i < (val - 1); i++) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
524 | query.next(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
525 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
526 | |
427
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
527 | newf.name = query.value("name").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
528 | newf.origin = query.value("origin").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
529 | newf.supplier = query.value("supplier").toString(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
530 | newf.cost = query.value("cost").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
531 | newf.type = query.value("type").toInt(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
532 | newf.yield = query.value("yield").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
533 | newf.color = query.value("color").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
534 | newf.coarse_fine_diff = query.value("coarse_fine_diff").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
535 | newf.moisture = query.value("moisture").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
536 | newf.diastatic_power = query.value("diastatic_power").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
537 | newf.protein = query.value("protein").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
538 | newf.dissolved_protein = query.value("dissolved_protein").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
539 | newf.max_in_batch = query.value("max_in_batch").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
540 | newf.graintype = query.value("graintype").toInt(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
541 | newf.recommend_mash = query.value("recommend_mash").toInt() ? true:false; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
542 | newf.add_after_boil = true; |
427
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
543 | newf.di_ph = query.value("di_ph").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
544 | newf.acid_to_ph_57 = query.value("acid_to_ph_57").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
545 | newf.inventory = query.value("inventory").toDouble(); |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
546 | newf.adjust_to_total_100 = false; |
1466eab37f53
Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
404
diff
changeset
|
547 | newf.percentage = 0; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
548 | newf.amount = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
549 | newf.added = FERMENTABLE_ADDED_KEGS; |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
550 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
551 | product->fermentables.append(newf); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
552 | refreshFermentables(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
553 | const QSignalBlocker blocker1(ui->keg_sugarEdit); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
554 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
555 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
556 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
557 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
558 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
559 | void EditProduct::kegs_water_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
560 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
561 | product->keg_priming_water = val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
562 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
563 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
564 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
565 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
566 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
567 | void EditProduct::kegs_forced_changed(bool val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
568 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
569 | qDebug() << "kegs_forced_changed" << val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
570 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
571 | product->keg_forced_carb = val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
572 | if (val) { |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
573 | /* |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
574 | * Make sure to remove priming sugars. |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
575 | */ |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
576 | for (int i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
577 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS) { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
578 | product->fermentables.removeAt(i); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
579 | refreshFermentables(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
580 | break; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
581 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
582 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
583 | product->keg_priming_sugar = 0; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
584 | product->keg_priming_amount = 0; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
585 | product->keg_priming_water = 0; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
586 | const QSignalBlocker blocker1(ui->keg_sugarEdit); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
587 | const QSignalBlocker blocker2(ui->keg_sug_waterEdit); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
588 | ui->keg_sugarEdit->setCurrentIndex(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
589 | ui->keg_sug_weightShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
590 | ui->keg_sug_waterEdit->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
591 | ui->keg_sug_amountShow->setValue(0); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
592 | } |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
593 | |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
594 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
595 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
596 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
597 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
598 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
599 | void EditProduct::kegs_temp_changed(double val) |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
600 | { |
223
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
601 | product->keg_carbonation_temp = val; |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
602 | calcPack(); |
37bac72eff61
Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents:
222
diff
changeset
|
603 | is_changed(); |
220
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
604 | } |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
605 | |
7792a410a277
Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
606 | |
297
c8f0ecc8a1cc
Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
607 | void EditProduct::carb_log_button() |
c8f0ecc8a1cc
Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
608 | { |
332
146874d7bb47
Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
298
diff
changeset
|
609 | ChartCarbonate dialog(product->code, product->name, this); |
297
c8f0ecc8a1cc
Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
610 | } |
c8f0ecc8a1cc
Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
611 |