src/EditProductTab11.cpp

Fri, 18 Nov 2022 12:17:32 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 18 Nov 2022 12:17:32 +0100
changeset 442
d8c110d91b1f
parent 439
31419b7cee69
child 443
3c195eb4e7a1
permissions
-rw-r--r--

Moved GetPressureBar function to the Utils.

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 double EditProduct::ResCO2(double T)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
21 {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
22 double F = T * 1.8 + 32;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
23 return round((3.0378 - 0.050062 * F + 0.00026555 * F * F) * 1000000.0) / 1000000.0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
24 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
25
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
26
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
27 double EditProduct::CarbCO2toS(double CO2, double T, double SFactor)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
28 {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
29 //var sugar = SFactor * (CO2 - ResCO2(CO2, T)) / 0.286;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
30 double sugar = round((SFactor * (CO2 - ResCO2(T)) * 4.014094) * 1000000.0) / 1000000.0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
31 if (sugar < 0)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
32 sugar = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
33 return sugar; //Round(sugar, 3);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
34 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
35
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
36
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
37 double EditProduct::GetPressure(double CO2, double T)
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
38 {
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
39 if (CO2 < 0)
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
40 return 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
41
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
42 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
43 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
44
31419b7cee69 Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents: 427
diff changeset
45 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
46 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
47 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
48 }
31419b7cee69 Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents: 427
diff changeset
49
31419b7cee69 Finally found the right way to calculate the bottle pressure in bar after refermentation.
Michiel Broek <mbroek@mbse.eu>
parents: 427
diff changeset
50
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
51 double EditProduct::CarbCO2ToPressure(double CO2, double T)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
52 {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
53 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
54 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) /
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
55 (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
56 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
57
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
59 void EditProduct::calcPack()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
60 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
61 int i, j;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
62 bool found1, found2;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
63 QSqlQuery query;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
64 double TSec, SFactor;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
65
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
66 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
67
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
68 if (product->package_volume < 1) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
69 /*
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
70 * If there is not enough to package, then don't
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
71 * do any calculations and clear the rest of the form.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
72 */
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
73 product->package_volume = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
74 ui->pack_finalabvShow->setValue(0);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
75
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
76 return;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
77 }
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
78
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
79 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
80 double balc = product->package_volume - bvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
81 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
82 double malc = product->package_infuse_amount - mvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
83 double talc = balc + malc;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
84 double tvol = bvol + mvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
85
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
86 product->final_abv = round(talc / (tvol + talc) * 10000.0) / 100.0;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
87 ui->pack_finalabvShow->setValue(product->final_abv);
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
88
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
89 TSec = product->secondary_temp;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
90 if (TSec < 1)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
91 TSec = product->primary_end_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 = 18;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
94
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
95 /*
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
96 * For bottles and kegs use the following complicated procedure to
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
97 * find the needed priming sugars.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
98 *
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
99 * 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
100 * 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
101 * 2. Then, we update the data from the fermentables inventory.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
102 * 3. Set the found sugar in the pulldown menu.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
103 * 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
104 * 5. Calculate the ABV in the bottles/kegs.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
105 * 6. Calculate the pressure build by the refermentation.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
106 *
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
107 * 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
108 * 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
109 * the right data and sugar concentrations.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
110 * Sometimes bugs have good things.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
111 */
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
112 found1 = false;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
113 if (product->bottle_amount) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
114 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
115 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
116 found1 = true;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
117 break;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
118 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
119 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
120 if (found1) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
121 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
122 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
123
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
124 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
125 query.exec();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
126 j = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
127 found2 = false;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
128 while (query.next()) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
129 j++;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
130 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
131 ui->bottle_sugarEdit->setCurrentIndex(j);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
132 product->bottle_priming_sugar = j;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
133 found2 = true;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
134 break;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
135 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
136 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
137 if (! found2) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
138 ui->bottle_sugarEdit->setCurrentIndex(0); // Make sure not selected
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
139 product->fermentables.removeAt(i); // Remove false fermentable
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
140 refreshFermentables();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
141 } else {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
142 product->bottle_priming_amount = CarbCO2toS(product->bottle_carbonation, TSec, SFactor);
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
143 // 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
144 ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
145 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
146 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
147 qDebug() << " total" << total << product->fermentables.at(i).amount;
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
148 qDebug() << " update priming sugar" << total;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
149 product->fermentables[i].amount = total;
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
150 refreshFermentables();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
151 is_changed();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
152 }
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
153 ui->bottle_sug_weightShow->setValue(total * 1000);
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
154
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
155 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
156 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
157 talc = product->bottle_amount - pvol;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
158 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
159 product->bottle_abv = talc / (tvol + talc) * 100;
442
d8c110d91b1f Moved GetPressureBar function to the Utils.
Michiel Broek <mbroek@mbse.eu>
parents: 439
diff changeset
160 product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount, 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
161 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
162 ui->bottle_barShow->setValue(product->bottle_bar);
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
163 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
164 }
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 if (! found1) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
167 qDebug() << " no bottle priming";
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
168 ui->bottle_sug_amountShow->setValue(0);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
169 ui->bottle_sug_weightShow->setValue(0);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
170 ui->bottle_abvShow->setValue(0);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
171 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
172 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
173 product->bottle_bar = 0;
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
174 }
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
175 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
176 ui->est_bottle_co2Show->setValue(product->bottle_carbonation);
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
177
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
178 ui->keg_sugarLabel->setEnabled(! product->keg_forced_carb);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
179 ui->keg_sugarEdit->setEnabled(! product->keg_forced_carb);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
180 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
181 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
182 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
183 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
184 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
185 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
186
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
187 found1 = false;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
188 if (product->keg_amount) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
189
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
190 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
191 if (Pressure < 0)
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
192 Pressure = 0;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
193 product->keg_pressure = Pressure;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
194 ui->keg_barShow->setValue(Pressure);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
195
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
196 if (! product->keg_forced_carb) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
197 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
198 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
199 found1 = true;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
200 break;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
201 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
202 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
203 if (found1) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
204 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
205 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
206
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
207 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
208 query.exec();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
209 j = 0;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
210 found2 = false;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
211 while (query.next()) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
212 j++;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
213 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
214 ui->keg_sugarEdit->setCurrentIndex(j);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
215 product->keg_priming_sugar = j;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
216 found2 = true;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
217 break;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
218 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
219 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
220 if (! found2) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
221 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
222 product->fermentables.removeAt(i); // Remove false fermentable
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
223 refreshFermentables();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
224 } else {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
225 product->keg_priming_amount = CarbCO2toS(product->keg_carbonation, TSec, SFactor);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
226 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
227 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
228 qDebug() << " total" << total << product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
229 if (total != product->fermentables.at(i).amount) {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
230 qDebug() << " update priming sugar" << total;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
231 product->fermentables[i].amount = total;
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
232 refreshFermentables();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
233 is_changed();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
234 }
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
235 ui->keg_sug_weightShow->setValue(total * 1000);
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
236
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
237 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
238 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
239 talc = product->keg_amount - pvol;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
240 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
241 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
242 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
243 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
244 ui->keg_barShow->setValue(product->keg_bar);
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
245 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
246 } // if priming sugar.
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
247 if (! found1) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
248 qDebug() << " no keg priming";
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
249 ui->keg_sug_amountShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
250 ui->keg_sug_weightShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
251 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
252 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
253 product->keg_bar = 0;
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
254 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
255 } else {
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 * Forced carbonation
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 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
260 product->keg_abv = product->final_abv;
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
261 ui->keg_sug_amountShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
262 ui->keg_sug_weightShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
263 }
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
264 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
265 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
266 } // if keg_amount
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
267 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
268
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 * Triggered by writing to ui->pack_abvShow
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 void EditProduct::pack_abv_changed(double val)
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 calcPack();
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
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 void EditProduct::pack_date_changed(QDate val)
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 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
282 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
283 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
284 setStage();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
285 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
286
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 void EditProduct::pack_date_button()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
289 {
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
290 ui->pack_dateEdit->setDate(QDate::currentDate());
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
291 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
292
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 void EditProduct::pack_date_ack()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
295 {
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
296 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
297 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
298
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 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
300 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
301
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 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
303 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
304 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
305 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
306
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 void EditProduct::pack_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
309 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
310 /*
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
311 * 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
312 * 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
313 */
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
314
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
315 product->package_volume = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
316 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
317 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
318 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
319
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 void EditProduct::pack_ph_changed(double val)
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 if (product->package_ph == 0) {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
324 product->package_ph = 4.0;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
325 const QSignalBlocker blocker1(ui->pack_phEdit);
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
326 ui->pack_phEdit->setValue(4.0);
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
327 } else {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
328 product->package_ph = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
329 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
330 is_changed();
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
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 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
335 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
336 product->package_infuse_amount = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
337 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
338 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
339 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
340
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 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
343 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
344 product->package_infuse_abv = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
345 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
346 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
347 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
348
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 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
351 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
352 product->package_infuse_notes = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
353 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
354 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
355
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 void EditProduct::bottle_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
358 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
359 /*
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
360 * 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
361 */
404
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
362 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
363 if (product->keg_amount < 0)
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
364 product->keg_amount = 0; /* Failsafe - bugfix */
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
365 if (val > product->package_volume) {
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
366 val = product->package_volume;
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
367 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
368 ui->bottle_volumeEdit->setValue(val);
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
369 }
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
370
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
371 if ((val + product->keg_amount) > product->package_volume) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
372 double kegs = product->package_volume - val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
373 product->keg_amount = kegs;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
374 ui->keg_volumeEdit->setValue(kegs);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
375 }
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
376 product->bottle_amount = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
377 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
378 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
379 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
380
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 void EditProduct::bottle_co2_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
383 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
384 product->bottle_carbonation = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
385 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
386 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
387 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
388
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 void EditProduct::bottle_sugar_changed(int val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
391 {
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
392 Fermentables newf;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
393 QSqlQuery query;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
394
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
395 qDebug() << "bottle_sugar_changed" << product->bottle_priming_sugar << val;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
396 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
397 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) {
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
398 product->fermentables.removeAt(i);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
399 refreshFermentables();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
400 break;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
401 }
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
402 }
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 * Search the sugar pointed by the index.
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 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
408 "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
409 "WHERE type = '1' OR type = '3' ORDER BY name";
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
410 query.prepare(sql);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
411 query.exec();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
412 query.first();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
413 for (int i = 0; i < (val - 1); i++) {
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
414 query.next();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
415 }
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
416
427
1466eab37f53 Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 404
diff changeset
417 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 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
429 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
430 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
431 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
432 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
433 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
434 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
435 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
436 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
437 newf.percentage = 0;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
438 newf.amount = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
439 newf.added = FERMENTABLE_ADDED_BOTTLE;
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
440
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
441 product->fermentables.append(newf);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
442 refreshFermentables();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
443 const QSignalBlocker blocker1(ui->bottle_sugarEdit);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
444 calcPack();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
445 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
446 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
447
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 void EditProduct::bottle_water_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
450 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
451 product->bottle_priming_water = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
452 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
453 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
454 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
455
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 void EditProduct::bottle_temp_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
458 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
459 product->bottle_carbonation_temp = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
460 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
461 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
462 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
463
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 void EditProduct::kegs_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
466 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
467 /*
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
468 * 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
469 */
404
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
470 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
471 if (product->bottle_amount < 0)
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
472 product->bottle_amount = 0; /* Failsafe - bugfix */
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
473 if (val > product->package_volume) {
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
474 val = product->package_volume;
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
475 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
476 ui->keg_volumeEdit->setValue(val);
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
477 }
47f1259378fe Fixed negative bottle of keg volumes and overflow totals.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
478
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
479 if ((val + product->bottle_amount) > product->package_volume) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
480 double bottle = product->package_volume - val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
481 product->bottle_amount = bottle;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
482 ui->bottle_volumeEdit->setValue(bottle);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
483 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
484 product->keg_amount = val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
485 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
486 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
487 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
488
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 void EditProduct::kegs_co2_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
491 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
492 product->keg_carbonation = val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
493 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
494 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
495 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
496
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 void EditProduct::kegs_sugar_changed(int val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
499 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
500 Fermentables newf;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
501 QSqlQuery query;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
502
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
503 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
504 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
505 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
506 product->fermentables.removeAt(i);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
507 refreshFermentables();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
508 break;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
509 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
510 }
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 * Search the sugar pointed by the index.
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 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
516 "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
517 "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
518 query.prepare(sql);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
519 query.exec();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
520 query.first();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
521 for (int i = 0; i < (val - 1); i++) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
522 query.next();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
523 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
524
427
1466eab37f53 Fix false adjust_to_total_100 setting in priming fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 404
diff changeset
525 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
526 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
527 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
528 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
529 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
530 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
531 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
532 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
533 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
534 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
535 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
536 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
537 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
538 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
539 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
540 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
541 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
542 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
543 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
544 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
545 newf.percentage = 0;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
546 newf.amount = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 238
diff changeset
547 newf.added = FERMENTABLE_ADDED_KEGS;
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
548
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
549 product->fermentables.append(newf);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
550 refreshFermentables();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
551 const QSignalBlocker blocker1(ui->keg_sugarEdit);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
552 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
553 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
554 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
555
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 void EditProduct::kegs_water_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
558 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
559 product->keg_priming_water = val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
560 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
561 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
562 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
563
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 void EditProduct::kegs_forced_changed(bool val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
566 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
567 qDebug() << "kegs_forced_changed" << val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
568
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
569 product->keg_forced_carb = val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
570 if (val) {
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
571 /*
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
572 * Make sure to remove priming sugars.
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 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
575 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
576 product->fermentables.removeAt(i);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
577 refreshFermentables();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
578 break;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
579 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
580 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
581 product->keg_priming_sugar = 0;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
582 product->keg_priming_amount = 0;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
583 product->keg_priming_water = 0;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
584 const QSignalBlocker blocker1(ui->keg_sugarEdit);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
585 const QSignalBlocker blocker2(ui->keg_sug_waterEdit);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
586 ui->keg_sugarEdit->setCurrentIndex(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
587 ui->keg_sug_weightShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
588 ui->keg_sug_waterEdit->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
589 ui->keg_sug_amountShow->setValue(0);
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
590 }
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
591
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
592 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
593 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
594 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
595
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 void EditProduct::kegs_temp_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
598 {
223
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
599 product->keg_carbonation_temp = val;
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
600 calcPack();
37bac72eff61 Added keg priming and forced carbonation.
Michiel Broek <mbroek@mbse.eu>
parents: 222
diff changeset
601 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
602 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
603
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
604
297
c8f0ecc8a1cc Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
605 void EditProduct::carb_log_button()
c8f0ecc8a1cc Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
606 {
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
607 ChartCarbonate dialog(product->code, product->name, this);
297
c8f0ecc8a1cc Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
608 }
c8f0ecc8a1cc Added co2pressure (carbonation) log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
609

mercurial