# HG changeset patch # User Michiel Broek # Date 1650115144 -7200 # Node ID 1189d072f346ce2cd8a5aab922e77645458dc8e1 # Parent ffe8b2e9517b5348fd577c606ec7ec19f50478b8 Add select target water profile. The mash part of the water tab is ready. diff -r ffe8b2e9517b -r 1189d072f346 src/EditRecipe.cpp --- a/src/EditRecipe.cpp Sat Apr 16 14:44:50 2022 +0200 +++ b/src/EditRecipe.cpp Sat Apr 16 15:19:04 2022 +0200 @@ -70,6 +70,13 @@ query.next(); } + query.prepare("SELECT name FROM profile_water ORDER BY name"); + query.exec(); + ui->wt_sourceEdit->addItem(""); + while (query.next()) { + ui->wt_sourceEdit->addItem(query.value(0).toString()); + } + ui->beerstyleEdit->addItem(""); // First add a dummy query.prepare("SELECT style_guide,style_letter,name FROM profile_styles ORDER BY style_guide,style_letter,name"); query.exec(); @@ -652,6 +659,7 @@ connect(ui->mw_phEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::on_mw_ph_changed); connect(ui->mw_acidvolEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::on_mw_acid_changed); connect(ui->mw_acidPick, QOverload::of(&QComboBox::currentIndexChanged), this, &EditRecipe::on_mw_type_changed); + connect(ui->wt_sourceEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditRecipe::on_target_changed); connect(ui->w2_volEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::on_w2_vol_changed); ui->saveButton->setEnabled(false); diff -r ffe8b2e9517b -r 1189d072f346 src/EditRecipe.h --- a/src/EditRecipe.h Sat Apr 16 14:44:50 2022 +0200 +++ b/src/EditRecipe.h Sat Apr 16 15:19:04 2022 +0200 @@ -304,6 +304,7 @@ void on_nahco3_changed(double val); void on_caco3_changed(double val); void on_calc_acid_clicked(); + void on_target_changed(int val); void on_mw_ph_changed(double val); void on_mw_acid_changed(double val); void on_mw_type_changed(int val); diff -r ffe8b2e9517b -r 1189d072f346 src/EditRecipeTab7.cpp --- a/src/EditRecipeTab7.cpp Sat Apr 16 14:44:50 2022 +0200 +++ b/src/EditRecipeTab7.cpp Sat Apr 16 15:19:04 2022 +0200 @@ -462,7 +462,6 @@ w = my_acids[recipe->wa_acid_name].name_en + ' ' + my_acids[recipe->wa_acid_name].name_nl; recipe->wa_acid_perc = my_acids.at(val).AcidPrc; -// ui->mw_acidPick->setCurrentIndex(val); ui->mw_acidpercEdit->setValue(my_acids.at(val).AcidPrc); brewing_salt_sub(w, ui->mw_acidvolEdit->value()); // For now, set old amount. @@ -477,6 +476,38 @@ } +void EditRecipe::on_target_changed(int val) +{ + QSqlQuery query; + + if (val == 0) { + /* Clear values */ + ui->wt_caEdit->setValue(0); + ui->wt_mgEdit->setValue(0); + ui->wt_hco3Edit->setValue(0); + ui->wt_caco3Edit->setValue(0); + ui->wt_naEdit->setValue(0); + ui->wt_clEdit->setValue(0); + ui->wt_so4Edit->setValue(0); + } else { + query.prepare("SELECT * FROM profile_water ORDER BY name"); + query.exec(); + query.first(); + for (int i = 0; i < (val - 1); i++) { + query.next(); + } + ui->wt_caEdit->setValue(query.value(2).toDouble()); + ui->wt_mgEdit->setValue(query.value(7).toDouble()); + ui->wt_hco3Edit->setValue(query.value(3).toDouble()); + ui->wt_caco3Edit->setValue(query.value(10).toDouble()); + ui->wt_naEdit->setValue(query.value(6).toDouble()); + ui->wt_clEdit->setValue(query.value(5).toDouble()); + ui->wt_so4Edit->setValue(query.value(4).toDouble()); + } + calcWater(); +} + + void EditRecipe::on_cacl2_changed(double val) { set_brewing_salt("CaCl2", val); } void EditRecipe::on_caso4_changed(double val) { set_brewing_salt("CaSO4", val); } void EditRecipe::on_mgso4_changed(double val) { set_brewing_salt("MgSO4", val); } diff -r ffe8b2e9517b -r 1189d072f346 ui/EditRecipe.ui --- a/ui/EditRecipe.ui Sat Apr 16 14:44:50 2022 +0200 +++ b/ui/EditRecipe.ui Sat Apr 16 15:19:04 2022 +0200 @@ -3229,6 +3229,9 @@ 23 + + If needed, choose a target water profile. +