diff -r 50b057ae50aa -r 7c9fb24bcc07 src/EditProduct.cpp --- a/src/EditProduct.cpp Sat Jun 08 16:58:52 2024 +0200 +++ b/src/EditProduct.cpp Sun Jun 09 11:47:41 2024 +0200 @@ -33,7 +33,6 @@ { QSqlQuery query, wquery, yquery; - qDebug() << "EditProduct record:" << id; product = new Product; ui->setupUi(this); product->fermentables_row = product->hops_row = product->miscs_row = product->yeasts_row = product->mashs_row = -1; @@ -185,10 +184,7 @@ product->eq_top_up_water = 0; product->eq_trub_loss = 0.5; product->eq_evap_rate = 1.8; -// product->eq_calc_boil_volume = true; product->eq_top_up_kettle = 0; -// product->eq_hop_utilization = 100; -// product->eq_lauter_volume = product->eq_lauter_height = product->eq_kettle_volume = product->eq_kettle_height = product->eq_mash_volume = 20; product->eq_lauter_deadspace = 0.5; product->eq_mash_max = 6; @@ -403,14 +399,14 @@ found = query.first(); } if (found) { - product->w1_calcium = query.value(3).toDouble(); - product->w1_magnesium = query.value(8).toDouble(); - product->w1_total_alkalinity = query.value(11).toDouble(); - product->w1_sodium = query.value(7).toDouble(); - product->w1_chloride = query.value(6).toDouble(); - product->w1_sulfate = query.value(5).toDouble(); - product->w1_ph = query.value(9).toDouble(); - ui->w1_nameEdit->setCurrentIndex(query.value(0).toInt()); + product->w1_calcium = query.value("calcium").toDouble(); + product->w1_magnesium = query.value("magnesium").toDouble(); + product->w1_total_alkalinity = query.value("total_alkalinity").toDouble(); + product->w1_sodium = query.value("sodium").toDouble(); + product->w1_chloride = query.value("chloride").toDouble(); + product->w1_sulfate = query.value("sulfate").toDouble(); + product->w1_ph = query.value("ph").toDouble(); + ui->w1_nameEdit->setCurrentIndex(query.value("record").toInt()); } else { product->w1_calcium = 0; product->w1_magnesium = 0; @@ -439,14 +435,14 @@ query.bindValue(":water", product->w2_name); query.exec(); if (query.first()) { - product->w2_calcium = query.value(3).toDouble(); - product->w2_magnesium = query.value(8).toDouble(); - product->w2_total_alkalinity = query.value(11).toDouble(); - product->w2_sodium = query.value(7).toDouble(); - product->w2_chloride = query.value(6).toDouble(); - product->w2_sulfate = query.value(5).toDouble(); - product->w2_ph = query.value(9).toDouble(); - ui->w2_nameEdit->setCurrentIndex(query.value(0).toInt()); + product->w2_calcium = query.value("calcium").toDouble(); + product->w2_magnesium = query.value("magnesium").toDouble(); + product->w2_total_alkalinity = query.value("total_alkalinity").toDouble(); + product->w2_sodium = query.value("sodium").toDouble(); + product->w2_chloride = query.value("chloride").toDouble(); + product->w2_sulfate = query.value("sulfate").toDouble(); + product->w2_ph = query.value("ph").toDouble(); + ui->w2_nameEdit->setCurrentIndex(query.value("record").toInt()); } else { product->w2_calcium = 0; product->w2_magnesium = 0; @@ -518,76 +514,13 @@ /* * At this point, see if we must upgrade the whole water part. - * Old is separated brew and sparge water. - * New is total water and divide into brew/sparge/spare water. - * Calculate brewing salts on the total. */ - if (product->sparge_source != 2) { +// if (product->sparge_source != 2) { + if (product->sparge_volume != (product->brew_sparge_est + product->eq_HLT_deadspace)) { qDebug() << "== Water settings upgrade =="; - qDebug() << " w1" << product->w1_amount << "w2" << product->w2_amount << "wg" << product->wg_amount << "sp" << product->sparge_volume << "se" << product->brew_sparge_est; + qDebug() << " sp" << product->sparge_volume << "se" << product->brew_sparge_est; qDebug() << " HLT " << product->eq_HLT_volume << " deadspace" << product->eq_HLT_deadspace; - double infused = 0; - for (int i = 0; i < product->mashs.size(); i++) { - if (product->mashs.at(i).step_type == 0) { // Infusion - infused += product->mashs.at(i).step_infuse_amount; - } - } - qDebug() << " mash infusion" << infused; -/* - double bs_cacl2 = 0, ss_cacl2 = 0; - double bs_caso4 = 0, ss_caso4 = 0; - double bs_mgso4 = 0, ss_mgso4 = 0; - double bs_nacl = 0, ss_nacl = 0; - double bs_mgcl2 = 0, ss_mgcl2 = 0; - double bs_nahco3 = 0; - double bs_caco3 = 0; - - for (int i = 0; i < product->miscs.size(); i++) { - if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_MASH) { - if (product->miscs.at(i).name == "CaCl2") { - bs_cacl2 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "CaSO4") { - bs_caso4 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "MgSO4") { - bs_mgso4 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "NaCl") { - bs_nacl = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "MgCl2") { - bs_mgcl2 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "NaHCO3") { - bs_nahco3 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "CaCO3") { - bs_caco3 = product->miscs.at(i).amount; - } - } else if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_SPARGE) { - if (product->miscs.at(i).name == "CaCl2") { - ss_cacl2 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "CaSO4") { - ss_caso4 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "MgSO4") { - ss_mgso4 = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "NaCl") { - ss_nacl = product->miscs.at(i).amount; - } else if (product->miscs.at(i).name == "MgCl2") { - ss_mgcl2 = product->miscs.at(i).amount; - } - } - } - if ((bs_cacl2 + ss_cacl2) > 0) - qDebug() << " CaCl2" << bs_cacl2 << ss_cacl2; - if ((bs_caso4 + ss_caso4) > 0) - qDebug() << " CaSO4" << bs_caso4 << ss_caso4; - if ((bs_mgso4 + ss_mgso4) > 0) - qDebug() << " MgSO4" << bs_mgso4 << ss_mgso4; - if ((bs_nacl + ss_nacl) > 0) - qDebug() << " NaCl" << bs_nacl << ss_nacl; - if ((bs_mgcl2 + ss_mgcl2) > 0) - qDebug() << " MgCl2" << bs_mgcl2 << ss_mgcl2; - if (bs_nahco3 > 0) - qDebug() << " NaHCO3" << bs_nahco3; - if (bs_caco3 > 0) - qDebug() << " CaCO3" << bs_caco3; -*/ + qDebug() << " fixed sparge supply" << (product->brew_sparge_est + product->eq_HLT_deadspace); } // Tab brewday. @@ -691,8 +624,6 @@ ui->taste_mouthfeelEdit->setText(product->taste_mouthfeel); ui->taste_aftertasteEdit->setText(product->taste_aftertaste); - qDebug() << "== Start connecting =="; - // Global signals connect(ui->tabWidget, &QTabWidget::currentChanged, this, &EditProduct::tab_changed); @@ -895,10 +826,9 @@ EditProduct::~EditProduct() { - qDebug() << "EditProduct done start"; delete ui; emit entry_changed(); - qDebug() << "EditProduct done final"; + qDebug() << "EditProduct done"; }