152 refreshFermentables(); |
152 refreshFermentables(); |
153 ui->bottle_sug_weightShow->setValue(total * 1000); |
153 ui->bottle_sug_weightShow->setValue(total * 1000); |
154 is_changed(); |
154 is_changed(); |
155 } |
155 } |
156 |
156 |
157 double pabv = product->final_abv + product->bottle_priming_amount * 0.47 / 7.907; |
157 double pabv = product->final_abv + (product->bottle_priming_amount * (1 / SFactor) * 0.47) / 7.907; |
158 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100; |
158 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100; |
159 talc = product->bottle_amount - pvol; |
159 talc = product->bottle_amount - pvol; |
160 tvol = pvol + product->bottle_priming_water; |
160 tvol = pvol + product->bottle_priming_water; |
161 ui->bottle_abvShow->setValue(talc / (tvol + talc) * 100); |
161 ui->bottle_abvShow->setValue(talc / (tvol + talc) * 100); |
162 ui->bottle_barShow->setValue(GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp)); |
162 ui->bottle_barShow->setValue(GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp)); |
260 } |
260 } |
261 |
261 |
262 |
262 |
263 void EditProduct::bottle_sugar_changed(int val) |
263 void EditProduct::bottle_sugar_changed(int val) |
264 { |
264 { |
|
265 Fermentables newf; |
|
266 QSqlQuery query; |
|
267 |
|
268 qDebug() << "bottle_sugar_changed" << product->bottle_priming_sugar << val; |
|
269 for (int i = 0; i < product->fermentables.size(); i++) { |
|
270 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE) { |
|
271 product->fermentables.removeAt(i); |
|
272 refreshFermentables(); |
|
273 break; |
|
274 } |
|
275 } |
|
276 |
|
277 /* |
|
278 * Search the sugar pointed by the index. |
|
279 */ |
|
280 QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch," |
|
281 "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57,inventory FROM inventory_fermentables " |
|
282 "WHERE type = '1' OR type = '3' ORDER BY name"; |
|
283 query.prepare(sql); |
|
284 query.exec(); |
|
285 query.first(); |
|
286 for (int i = 0; i < (val - 1); i++) { |
|
287 query.next(); |
|
288 } |
|
289 |
|
290 newf.f_name = query.value(0).toString(); |
|
291 newf.f_origin = query.value(1).toString(); |
|
292 newf.f_supplier = query.value(2).toString(); |
|
293 newf.f_cost = query.value(3).toDouble(); |
|
294 newf.f_type = query.value(4).toInt(); |
|
295 newf.f_yield = query.value(5).toDouble(); |
|
296 newf.f_color = query.value(6).toDouble(); |
|
297 newf.f_coarse_fine_diff = query.value(7).toDouble(); |
|
298 newf.f_moisture = query.value(8).toDouble(); |
|
299 newf.f_diastatic_power = query.value(9).toDouble(); |
|
300 newf.f_protein = query.value(10).toDouble(); |
|
301 newf.f_dissolved_protein = query.value(11).toDouble(); |
|
302 newf.f_max_in_batch = query.value(12).toDouble(); |
|
303 newf.f_graintype = query.value(13).toInt(); |
|
304 newf.f_recommend_mash = query.value(14).toInt() ? true:false; |
|
305 newf.f_add_after_boil = true; |
|
306 newf.f_di_ph = query.value(16).toDouble(); |
|
307 newf.f_acid_to_ph_57 = query.value(17).toDouble(); |
|
308 newf.f_inventory = query.value(18).toDouble(); |
|
309 newf.f_amount = 0; |
|
310 newf.f_added = FERMENTABLE_ADDED_BOTTLE; |
|
311 |
|
312 product->fermentables.append(newf); |
|
313 refreshFermentables(); |
|
314 const QSignalBlocker blocker1(ui->bottle_sugarEdit); |
|
315 calcPack(); |
|
316 is_changed(); |
265 } |
317 } |
266 |
318 |
267 |
319 |
268 void EditProduct::bottle_water_changed(double val) |
320 void EditProduct::bottle_water_changed(double val) |
269 { |
321 { |