src/EditProductTab11.cpp

Thu, 19 May 2022 22:29:24 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 19 May 2022 22:29:24 +0200
changeset 222
c5a3beb15eef
parent 221
54828816233f
child 223
37bac72eff61
permissions
-rw-r--r--

Replace priming sugar implemented.

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
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
37 double EditProduct::GetPressure(double CO2, double T1, double T2)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
38 {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
39 double V = CO2 - ResCO2(T1);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
40 V = CO2; // TODO: temp only total pressure, testing
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
41 if (V < 0)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
42 return 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
43
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
44 double P = -1.09145427669121 + 0.00800006989646477 * T2 + 0.000260276315484684 * T2 * T2 + 0.0215142075945119 * T2 * V +
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
45 0.674996600795854 * V + -0.00471757220150754 * V * V;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
46 if (P < 0)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
47 P = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
48 P = round((P * 1.01325) * 100.0) / 100.0; // atm to bar
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
49 qDebug() << " GetPressure(" << CO2 << "," << T1 << "," << T2 << ") V:" << V << "Bar:" << P << "ignored ResCO2:" << ResCO2(T1);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
50 return P;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
51 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
52
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
53
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
54 double EditProduct::CarbCO2ToPressure(double CO2, double T)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
55 {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
56 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
57 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) /
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
58 (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
59 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
60
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
62 void EditProduct::calcPack()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
63 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
64 int i, j;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
65 bool found1, found2;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
66 QSqlQuery query;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
67 double TSec, SFactor;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
68
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
69 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
70
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
71 if (product->package_volume < 1) {
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 * If there is not enough to package, then don't
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
74 * do any calculations and clear the rest of the form.
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 product->package_volume = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
77 ui->pack_finalabvShow->setValue(0);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
78
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
79 return;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
80 }
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
81
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
82 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
83 double balc = product->package_volume - bvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
84 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
85 double malc = product->package_infuse_amount - mvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
86 double talc = balc + malc;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
87 double tvol = bvol + mvol;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
88
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
89 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
90 ui->pack_finalabvShow->setValue(product->final_abv);
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
91
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
92 TSec = product->secondary_temp;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
93 if (TSec < 1)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
94 TSec = product->primary_end_temp;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
95 if (TSec < 1)
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
96 TSec = 18;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
97
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
98 /*
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
99 * For bottles and kegs use the following complicated procedure to
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
100 * find the needed priming sugars.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
101 *
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
102 * 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
103 * 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
104 * 2. Then, we update the data from the fermentables inventory.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
105 * 3. Set the found sugar in the pulldown menu.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
106 * 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
107 * 5. Calculate the ABV in the bottles/kegs.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
108 * 6. Calculate the pressure build by the refermentation.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
109 *
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
110 * 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
111 * 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
112 * the right data and sugar concentrations.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
113 * Sometimes bugs have good things.
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
114 */
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
115 found1 = false;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
116 if (product->bottle_amount) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
117 for (i = 0; i < product->fermentables.size(); i++) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
118 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
119 found1 = true;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
120 break;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
121 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
122 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
123 if (found1) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
124 SFactor = 1 / ((product->fermentables.at(i).f_yield / 100) * (1 - product->fermentables.at(i).f_moisture / 100));
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
125 qDebug() << " bottle sugar" << product->fermentables.at(i).f_name << SFactor << TSec;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
126
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
127 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
128 query.exec();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
129 j = 0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
130 found2 = false;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
131 while (query.next()) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
132 j++;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
133 if (query.value(0).toString() == product->fermentables.at(i).f_name && query.value(1).toString() == product->fermentables.at(i).f_supplier) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
134 ui->bottle_sugarEdit->setCurrentIndex(j);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
135 product->bottle_priming_sugar = j;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
136 found2 = true;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
137 break;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
138 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
139 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
140 if (! found2) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
141 ui->bottle_sugarEdit->setCurrentIndex(0); // Make sure not selected
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
142 product->fermentables.removeAt(i); // Remove false fermentable
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
143 refreshFermentables();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
144 } else {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
145 product->bottle_priming_amount = CarbCO2toS(product->bottle_carbonation, TSec, SFactor);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
146 ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
147 double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
148 qDebug() << " total" << total << product->fermentables.at(i).f_amount;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
149 if (total != product->fermentables.at(i).f_amount) {
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
150 qDebug() << " update priming sugar" << total;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
151 product->fermentables[i].f_amount = total;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
152 refreshFermentables();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
153 ui->bottle_sug_weightShow->setValue(total * 1000);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
154 is_changed();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
155 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
156
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
157 double pabv = product->final_abv + (product->bottle_priming_amount * (1 / SFactor) * 0.47) / 7.907;
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
158 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
159 talc = product->bottle_amount - pvol;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
160 tvol = pvol + product->bottle_priming_water;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
161 ui->bottle_abvShow->setValue(talc / (tvol + talc) * 100);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
162 ui->bottle_barShow->setValue(GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp));
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);
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
172 }
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
173
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
174 // keg_amount keg_carbonation keg_priming_sugar keg_priming_amount keg_priming_water keg_carbonation_temp keg_forced_carb keg_pressure
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
175 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
176
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
177
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
178 /*
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
179 * Triggered by writing to ui->pack_abvShow
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
180 */
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
181 void EditProduct::pack_abv_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
182 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
183 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
184 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
185
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
186
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
187 void EditProduct::pack_date_changed(QDate val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
188 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
189 qDebug() << "pack_date_changed" << val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
190 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
191
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
192
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
193 void EditProduct::pack_date_button()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
194 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
195 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
196
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
197
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
198 void EditProduct::pack_date_ack()
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
199 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
200 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
201
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
202
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
203 void EditProduct::pack_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
204 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
205 product->package_volume = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
206 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
207 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
208 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
209
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
210
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
211 void EditProduct::pack_ph_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
212 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
213 if (product->package_ph == 0) {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
214 product->package_ph = 4.0;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
215 const QSignalBlocker blocker1(ui->pack_phEdit);
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
216 ui->pack_phEdit->setValue(4.0);
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
217 } else {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
218 product->package_ph = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
219 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
220 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
221 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
222
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
223
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
224 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
225 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
226 product->package_infuse_amount = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
227 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
228 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
229 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
230
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
231
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
232 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
233 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
234 product->package_infuse_abv = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
235 calcPack();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
236 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
237 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
238
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
239
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
240 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
241 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
242 product->package_infuse_notes = val;
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
243 is_changed();
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
244 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
245
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
246
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
247 void EditProduct::bottle_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
248 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
249 product->bottle_amount = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
250 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
251 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
252 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
253
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
254
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
255 void EditProduct::bottle_co2_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
256 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
257 product->bottle_carbonation = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
258 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
259 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
260 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
261
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
262
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
263 void EditProduct::bottle_sugar_changed(int val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
264 {
222
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
265 Fermentables newf;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
266 QSqlQuery query;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
267
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
268 qDebug() << "bottle_sugar_changed" << product->bottle_priming_sugar << val;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
269 for (int i = 0; i < product->fermentables.size(); i++) {
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
270 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE) {
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
271 product->fermentables.removeAt(i);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
272 refreshFermentables();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
273 break;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
274 }
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
275 }
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
276
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
277 /*
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
278 * Search the sugar pointed by the index.
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
279 */
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
280 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
281 "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
282 "WHERE type = '1' OR type = '3' ORDER BY name";
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
283 query.prepare(sql);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
284 query.exec();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
285 query.first();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
286 for (int i = 0; i < (val - 1); i++) {
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
287 query.next();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
288 }
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
289
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
290 newf.f_name = query.value(0).toString();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
291 newf.f_origin = query.value(1).toString();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
292 newf.f_supplier = query.value(2).toString();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
293 newf.f_cost = query.value(3).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
294 newf.f_type = query.value(4).toInt();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
295 newf.f_yield = query.value(5).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
296 newf.f_color = query.value(6).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
297 newf.f_coarse_fine_diff = query.value(7).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
298 newf.f_moisture = query.value(8).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
299 newf.f_diastatic_power = query.value(9).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
300 newf.f_protein = query.value(10).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
301 newf.f_dissolved_protein = query.value(11).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
302 newf.f_max_in_batch = query.value(12).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
303 newf.f_graintype = query.value(13).toInt();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
304 newf.f_recommend_mash = query.value(14).toInt() ? true:false;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
305 newf.f_add_after_boil = true;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
306 newf.f_di_ph = query.value(16).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
307 newf.f_acid_to_ph_57 = query.value(17).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
308 newf.f_inventory = query.value(18).toDouble();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
309 newf.f_amount = 0;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
310 newf.f_added = FERMENTABLE_ADDED_BOTTLE;
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
311
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
312 product->fermentables.append(newf);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
313 refreshFermentables();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
314 const QSignalBlocker blocker1(ui->bottle_sugarEdit);
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
315 calcPack();
c5a3beb15eef Replace priming sugar implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
316 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
317 }
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 void EditProduct::bottle_water_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
321 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
322 product->bottle_priming_water = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
323 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
324 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
325 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
326
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
327
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
328 void EditProduct::bottle_temp_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
329 {
221
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
330 product->bottle_carbonation_temp = val;
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
331 calcPack();
54828816233f Added bottles priming calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
332 is_changed();
220
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
333 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
334
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
335
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
336 void EditProduct::kegs_volume_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
337 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
338 }
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 void EditProduct::kegs_co2_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
342 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
343 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
344
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
345
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
346 void EditProduct::kegs_sugar_changed(int val)
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
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
351 void EditProduct::kegs_water_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
352 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
353 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
354
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 void EditProduct::kegs_forced_changed(bool val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
357 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
358 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
359
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
360
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
361 void EditProduct::kegs_temp_changed(double val)
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
362 {
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
363 }
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
364
7792a410a277 Added first part of the package tab.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
365

mercurial