Fri, 13 Jan 2023 12:00:58 +0100
Added a button to automatic recreate the yeast starter steps. Some code cleanup
/** * EditProduct.cpp is part of bmsapp. * * Tab 2, equipment settings. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ void EditProduct::showEquipment() { ui->eq_nameEdit->setText(product->eq_name); ui->eq_notesEdit->setPlainText(product->eq_notes); /* Mashing */ ui->tun_volumeEdit->setValue(product->eq_tun_volume); ui->tun_materialEdit->setText(QCoreApplication::translate("TunMaterial", g_tun_materials[product->eq_tun_material])); ui->mash_volumeEdit->setValue(product->eq_mash_volume); ui->mash_maxEdit->setValue(product->eq_mash_max); /* Lautering */ ui->lauter_deadspaceEdit->setValue(product->eq_lauter_deadspace); ui->eq_efficiencyEdit->setValue(product->eq_efficiency); /* Boiling */ ui->kettle_volumeEdit->setValue(product->eq_kettle_volume); ui->kettle_lossEdit->setValue(product->eq_trub_chiller_loss); ui->eqboil_sizeEdit->setValue(product->eq_boil_size); ui->evap_rateEdit->setValue(product->eq_evap_rate); ui->eqboil_timeEdit->setValue(product->eq_boil_time); ui->topup_kettleEdit->setValue(product->eq_top_up_kettle); ui->eqbatch_sizeEdit->setValue(product->eq_batch_size); /* Chilling */ ui->chiller_typeEdit->setText(QCoreApplication::translate("ChillerType", g_chiller_types[product->eq_chiller_type])); ui->brew_coolwithShow->setText(QCoreApplication::translate("ChillerType", g_chiller_types[product->eq_chiller_type])); ui->chiller_to79Edit->setValue(product->eq_chiller_to79); ui->chiller_volumeEdit->setValue(product->eq_chiller_volume); ui->chiller_lpmEdit->setValue(product->eq_chiller_lpm); ui->chiller_lossEdit->setValue(product->eq_chiller_loss); /* Transfer */ ui->topup_waterEdit->setValue(product->eq_top_up_water); ui->vol_fermenterEdit->setValue((product->eq_batch_size / 1.04) - product->eq_trub_chiller_loss - product->eq_chiller_loss); } void EditProduct::initEquipment() { QSqlQuery query; ui->eq_selectEdit->addItem(""); query.prepare("SELECT name FROM inventory_equipments ORDER BY name"); query.exec(); while (query.next()) { ui->eq_selectEdit->addItem(query.value(0).toString()); } connect(ui->eq_selectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::eq_changed); showEquipment(); } void EditProduct::eq_changed(int val) { QSqlQuery query; if (val == 0) return; qDebug() << "equipment changed" << val; query.prepare("SELECT * FROM inventory_equipments ORDER BY name"); query.exec(); query.first(); for (int i; i < (val - 1); i++) { query.next(); } qDebug() << "got" << query.value("name").toString(); product->eq_name = query.value("name").toString(); product->eq_notes = query.value("notes").toString(); product->eq_boil_size = query.value("boil_size").toDouble(); product->eq_batch_size = query.value("batch_size").toDouble(); product->eq_tun_volume = query.value("tun_volume").toDouble(); product->eq_tun_weight = query.value("tun_weight").toDouble(); product->eq_tun_specific_heat = query.value("tun_specific_heat").toDouble(); product->eq_tun_material = query.value("tun_material").toInt(); product->eq_tun_height = query.value("tun_height").toDouble(); product->eq_top_up_water = query.value("top_up_water").toDouble(); product->eq_trub_chiller_loss = query.value("trub_chiller_loss").toDouble(); product->eq_evap_rate = query.value("evap_rate").toDouble(); product->eq_boil_time = query.value("boil_time").toDouble(); //product->eq_calc_boil_volume = query.value("calc_boil_volume").toInt() ? true:false; product->eq_top_up_kettle = query.value("top_up_kettle").toDouble(); //product->eq_hop_utilization = query.value("hop_utilization").toDouble(); //product->eq_lauter_volume = query.value("lauter_volume").toDouble(); //product->eq_lauter_height = query.value("lauter_height").toDouble(); product->eq_lauter_deadspace = query.value("lauter_deadspace").toDouble(); product->eq_kettle_volume = query.value("kettle_volume").toDouble(); product->eq_kettle_height = query.value("kettle_height").toDouble(); product->eq_mash_volume = query.value("mash_volume").toDouble(); product->eq_mash_max = query.value("mash_max").toDouble(); product->eq_efficiency = query.value("efficiency").toDouble(); product->eq_chiller_type = product->brew_cooling_method = query.value("chiller_type").toInt(); product->eq_chiller_to79 = query.value("chiller_to79").toDouble(); product->eq_chiller_volume = query.value("chiller_volume").toDouble(); product->eq_chiller_lpm = query.value("chiller_lpm").toDouble(); product->eq_chiller_loss = query.value("chiller_loss").toDouble(); showEquipment(); /* * Now change some important settings and recalculate the recipe parts. */ double factor = product->eq_batch_size / product->batch_size; double estog = product->est_og; const QSignalBlocker blocker1(ui->batch_sizeEdit); const QSignalBlocker blocker2(ui->boil_sizeEdit); const QSignalBlocker blocker3(ui->boil_timeEdit); const QSignalBlocker blocker4(ui->efficiencyEdit); product->boil_size = product->eq_boil_size; product->boil_time = product->eq_boil_time; product->batch_size = product->eq_batch_size; product->efficiency = product->eq_efficiency; ui->batch_sizeEdit->setValue(product->batch_size); ui->boil_sizeEdit->setValue(product->boil_size); ui->boil_timeEdit->setValue(product->boil_time); ui->efficiencyEdit->setValue(product->efficiency); ui->brew_preboilvolShow->setValue(product->boil_size * 1.04); ui->brew_aboilvolShow->setValue(product->batch_size * 1.04); calcFermentablesFromOG(estog); adjustWaters(factor); calcFermentables(); adjustHops(factor); adjustMiscs(factor); adjustYeasts(factor); calcIBUs(); calcWater(); calcMash(); is_changed(); emit refreshAll(); }