# HG changeset patch # User Michiel Broek # Date 1651524139 -7200 # Node ID 722a4eed545d38ce370bb6ac5a8526b357d88d55 # Parent ff09c95d9e449e08c0f80ab1d8e5f6710e436e9f Added select equipment. diff -r ff09c95d9e44 -r 722a4eed545d src/EditProduct.cpp --- a/src/EditProduct.cpp Mon May 02 21:09:48 2022 +0200 +++ b/src/EditProduct.cpp Mon May 02 22:42:19 2022 +0200 @@ -796,7 +796,7 @@ ui->est_carbShow->setValue(product->est_carb); // Tab equipment. - showEquipment(); + initEquipment(); // Tab fermentables. ui->est_og2Edit->setValue(product->est_og); diff -r ff09c95d9e44 -r 722a4eed545d src/EditProduct.h --- a/src/EditProduct.h Mon May 02 21:09:48 2022 +0200 +++ b/src/EditProduct.h Mon May 02 22:42:19 2022 +0200 @@ -48,6 +48,7 @@ void batch_size_changed(double val); void brew_type_changed(int val); void locked_changed(bool val); + void eq_changed(int val); void refreshFermentables(); void refreshHops(); void refreshMiscs(); @@ -159,6 +160,7 @@ static bool yeast_sort_test(const Yeasts &D1, const Yeasts &D2); void WindowTitle(); void showEquipment(); + void initEquipment(); void setStage(); void brewing_salt_sub(QString salt, double val); void set_brewing_salt(QString salt, double val); diff -r ff09c95d9e44 -r 722a4eed545d src/EditProductTab1.cpp --- a/src/EditProductTab1.cpp Mon May 02 21:09:48 2022 +0200 +++ b/src/EditProductTab1.cpp Mon May 02 22:42:19 2022 +0200 @@ -162,7 +162,6 @@ adjustYeasts(factor); calcIBUs(); calcWater(); - //calcSparge(); calcMash(); is_changed(); emit refreshAll(); @@ -195,6 +194,20 @@ int stage = product->stage; bool locked = product->locked; + /* + * See if we need to set a new stage. + */ + if ((stage == PROD_STAGE_PLAN) && (product->est_og > 1.005) && (product->est_color > 3) && (product->est_ibu > 3)) + stage = 1; + + if (product->stage != stage) { + qDebug() << "setStage() change state:" << prod_stages[product->stage] << "to:" << prod_stages[stage]; + product->stage = stage; + is_changed(); + } else { + qDebug() << "setStage() stage:" << prod_stages[stage]; + } + ui->stageEdit->setText(prod_stages[stage]); /* Tab 1, generic */ @@ -215,27 +228,31 @@ ui->efficiencyEdit->setButtonSymbols((stage > PROD_STAGE_WAIT) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows); ui->est_ogEdit->setReadOnly(stage > PROD_STAGE_WAIT); ui->est_ogEdit->setButtonSymbols((stage > PROD_STAGE_WAIT) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows); + // Block locked if stage <= PROD_STAGE_TASTE - /* Tab 2, fermentables */ + /* Tab 2, equipment */ + ui->tabWidget->setTabEnabled(1, stage < PROD_STAGE_BREW); + + /* Tab 3, fermentables */ ui->est_og2Edit->setReadOnly(stage > PROD_STAGE_WAIT); ui->est_og2Edit->setButtonSymbols((stage > PROD_STAGE_WAIT) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows); ui->addFermentable->setEnabled(stage <= PROD_STAGE_PACKAGE); - /* Tab 3, hops */ + /* Tab 4, hops */ ui->addHop->setEnabled(stage <= PROD_STAGE_PACKAGE); - /* Tab 4, miscs */ + /* Tab 5, miscs */ ui->addMisc->setEnabled(stage <= PROD_STAGE_PACKAGE); - /* Tab 5, yeasts */ + /* Tab 6, yeasts */ ui->addYeast->setEnabled(stage <= PROD_STAGE_PACKAGE); - /* Tab 6, mash */ + /* Tab 7, mash */ ui->addMash->setEnabled(stage <= PROD_STAGE_BREW); ui->mash_nameEdit->setReadOnly(stage > PROD_STAGE_BREW); ui->mash_pickEdit->setDisabled(stage > PROD_STAGE_BREW); - /* Tab 7, water */ + /* Tab 8, water */ ui->sp_sourceEdit->setDisabled(stage > PROD_STAGE_BREW); ui->wt_sourceEdit->setDisabled(stage > PROD_STAGE_BREW); ui->w1_nameEdit->setDisabled(stage > PROD_STAGE_BREW); @@ -276,6 +293,21 @@ ui->mw_acidvolEdit->setButtonSymbols(product->calc_acid ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows); } ui->mw_autoEdit->setDisabled(stage > PROD_STAGE_BREW); + + /* Tab 9, brewday */ + ui->tabWidget->setTabEnabled(8, stage > PROD_STAGE_PLAN); + + /* Tab 10, fermentation */ + ui->tabWidget->setTabEnabled(9, stage > PROD_STAGE_PLAN); + + + /* Tab 11, packaging */ + ui->tabWidget->setTabEnabled(10, stage > PROD_STAGE_PLAN); + + + /* Tab 12, tasting */ + ui->tabWidget->setTabEnabled(11, stage > PROD_STAGE_PLAN); + } diff -r ff09c95d9e44 -r 722a4eed545d src/EditProductTab2.cpp --- a/src/EditProductTab2.cpp Mon May 02 21:09:48 2022 +0200 +++ b/src/EditProductTab2.cpp Mon May 02 22:42:19 2022 +0200 @@ -49,3 +49,96 @@ } +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::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(); + 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); + + calcFermentablesFromOG(estog); + adjustWaters(factor); + calcFermentables(); + adjustHops(factor); + adjustMiscs(factor); + adjustYeasts(factor); + calcIBUs(); + calcWater(); + calcMash(); + is_changed(); + emit refreshAll(); +} + +