# HG changeset patch # User Michiel Broek # Date 1650628019 -7200 # Node ID 58e4ce7dd2170f173b56db26376cf96cadb7f8b5 # Parent b5b2483f3a3f65764998774cb6da9eca7eceb47c Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed. diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipe.cpp --- a/src/EditRecipe.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipe.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -24,7 +24,7 @@ EditRecipe::EditRecipe(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditRecipe) { - QSqlQuery query, wquery; + QSqlQuery query, wquery, yquery; qDebug() << "EditRecipe record:" << id; recipe = new Recipe; @@ -96,7 +96,11 @@ query.prepare("SELECT * FROM recipes WHERE record = :recno"); query.bindValue(":recno", id); query.exec(); - query.next(); + query.first(); + + QSqlRecord rec = query.record(); + for (int i = 0; i < rec.count(); i++) + qDebug() << i << rec.fieldName(i) << query.value(i); recipe->record = query.value(0).toInt(); recipe->uuid = query.value(1).toString(); @@ -299,7 +303,7 @@ } else if (yeasts.isArray()) { for (int i = 0; i < yeasts.array().size(); i++) { QJsonObject obj = yeasts.array().at(i).toObject(); - qDebug() << i << obj; + //qDebug() << i << obj; Yeasts y; /* First some defaults for newer fields. */ y.y_tolerance = y.y_harvest_time = y.y_pitch_temperature = y.y_zymocide = 0; @@ -336,31 +340,31 @@ y.y_sg_hi = obj["y_sg_hi"].toDouble(); y.y_cost = obj["y_cost"].toDouble(); - if (y.y_tolerance == 0) { // More and better tests? + if (y.y_tolerance == 0 || y.y_cells == 0) { // More and better tests? /* * Possible data upgrade needed. */ - query.prepare("SELECT tolerance,cells,sta1,bacteria,harvest_top,harvest_time,pitch_temperature," - "pofpos,zymocide,gr_hl_lo,sg_lo,gr_hl_hi,sg_hi " - "FROM inventory_yeasts WHERE name=:name AND laboratory=:laboratory AND product_id=:product_id"); - query.bindValue(":name", y.y_name); - query.bindValue(":laboratory", y.y_laboratory); - query.bindValue(":product_id", y.y_product_id); - query.exec(); - if (query.first()) { - y.y_tolerance = query.value(0).toDouble(); - y.y_cells = query.value(1).toDouble(); - y.y_sta1 = query.value(2).toInt() ? true:false; - y.y_bacteria = query.value(3).toInt() ? true:false; - y.y_harvest_top = query.value(4).toInt() ? true:false; - y.y_harvest_time = query.value(5).toInt(); - y.y_pitch_temperature = query.value(6).toDouble(); - y.y_pofpos = query.value(7).toInt() ? true:false; - y.y_zymocide = query.value(8).toInt(); - y.y_gr_hl_lo = query.value(9).toInt(); - y.y_sg_lo = query.value(10).toDouble(); - y.y_gr_hl_hi = query.value(11).toInt(); - y.y_sg_hi = query.value(12).toDouble(); + yquery.prepare("SELECT tolerance,cells,sta1,bacteria,harvest_top,harvest_time,pitch_temperature," + "pofpos,zymocide,gr_hl_lo,sg_lo,gr_hl_hi,sg_hi " + "FROM inventory_yeasts WHERE name=:name AND laboratory=:laboratory AND product_id=:product_id"); + yquery.bindValue(":name", y.y_name); + yquery.bindValue(":laboratory", y.y_laboratory); + yquery.bindValue(":product_id", y.y_product_id); + yquery.exec(); + if (yquery.first()) { + y.y_tolerance = yquery.value(0).toDouble(); + y.y_cells = yquery.value(1).toDouble(); + y.y_sta1 = yquery.value(2).toInt() ? true:false; + y.y_bacteria = yquery.value(3).toInt() ? true:false; + y.y_harvest_top = yquery.value(4).toInt() ? true:false; + y.y_harvest_time = yquery.value(5).toInt(); + y.y_pitch_temperature = yquery.value(6).toDouble(); + y.y_pofpos = yquery.value(7).toInt() ? true:false; + y.y_zymocide = yquery.value(8).toInt(); + y.y_gr_hl_lo = yquery.value(9).toInt(); + y.y_sg_lo = yquery.value(10).toDouble(); + y.y_gr_hl_hi = yquery.value(11).toInt(); + y.y_sg_hi = yquery.value(12).toDouble(); } else { qDebug() << y.y_name << y.y_product_id << "not found for upgrade"; } @@ -373,8 +377,7 @@ qDebug() << "empty yeasts"; } -qDebug() << query.value(88).toString(); - const auto& ma_json = query.value(88).toString(); + const auto& ma_json = query.value("json_mashs").toString().trimmed(); if (!ma_json.trimmed().isEmpty()) { const auto& formattedJson = QString("%1").arg(ma_json); QJsonDocument mashs = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); @@ -1041,6 +1044,7 @@ if (recipe->mashs.size() == 0) { query.bindValue(":json_mashs", "[]"); + qDebug() << "Saved empty mashs"; } else { QJsonArray array; for (int i = 0; i < recipe->mashs.size(); i++) { @@ -1060,7 +1064,7 @@ } QJsonDocument doc; doc.setArray(array); -// qDebug() << doc.toJson(QJsonDocument::Compact); + qDebug() << doc.toJson(QJsonDocument::Compact); query.bindValue(":json_mashs", doc.toJson(QJsonDocument::Compact)); } diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipe.h --- a/src/EditRecipe.h Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipe.h Fri Apr 22 13:46:59 2022 +0200 @@ -373,7 +373,6 @@ QString bar_100 = "QProgressBar::chunk {background: #80FF80;}"; int recno; bool textIsChanged = false; - bool ignoreChanges = false; Recipe *recipe; /* * Variables for popup ingredients editing. @@ -384,7 +383,7 @@ QDoubleSpinBox *steptempEdit, *endtempEdit, *steptimeEdit, *ramptimeEdit, *stepivolEdit, *stepitmpEdit; QSpinBox *htimeEdit, *mtimeEdit; QCheckBox *to100Edit, *finstockEdit, *hinstockEdit, *minstockEdit, *yinstockEdit; - QLabel *htimeLabel, *mtimeLabel, *mamountLabel, *ivolLabel, *itmpLabel; + QLabel *htimeLabel, *mtimeLabel, *mamountLabel, *yamountLabel, *ivolLabel, *itmpLabel; void to100Fermentables(int row); static bool ferment_sort_test(const Fermentables &D1, const Fermentables &D2); diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipeTab2.cpp --- a/src/EditRecipeTab2.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipeTab2.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -494,7 +494,6 @@ if (rc == QMessageBox::No) return; -// this->ignoreChanges = true; recipe->fermentables.removeAt(row); /* @@ -508,7 +507,6 @@ if (recipe->fermentables.at(i).f_added < 4) recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100; -// this->ignoreChanges = false; is_changed(); emit refreshAll(); } @@ -523,7 +521,6 @@ return; qDebug() << "ferment_amount_changed()" << recipe->fermentables_row << val; -// this->ignoreChanges = true; recipe->fermentables[recipe->fermentables_row].f_amount = val; item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0')); @@ -547,7 +544,6 @@ this->pctEdit->setValue(perc); } } -// this->ignoreChanges = false; is_changed(); } @@ -576,7 +572,6 @@ double diffw = (diffp / 100) * total; qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp; -// this->ignoreChanges = true; recipe->fermentables[recipe->fermentables_row].f_percentage += diffp; recipe->fermentables[recipe->fermentables_row].f_amount += diffw; recipe->fermentables[row100].f_percentage -= diffp; @@ -599,7 +594,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(row100, 8, item); -// this->ignoreChanges = false; is_changed(); } @@ -644,11 +638,9 @@ return; } -// this->ignoreChanges = true; for (int i = 0; i < recipe->fermentables.size(); i++) { to100Fermentables(i); } -// this->ignoreChanges = false; is_changed(); } @@ -763,7 +755,6 @@ { qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val; -// this->ignoreChanges = true; recipe->fermentables[recipe->fermentables_row].f_added = val; QTableWidgetItem *item = new QTableWidgetItem(f_added[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); @@ -780,7 +771,6 @@ if (recipe->fermentables.at(i).f_added < 4) recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100; -// this->ignoreChanges = false; is_changed(); emit refreshAll(); } diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipeTab3.cpp --- a/src/EditRecipeTab3.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipeTab3.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -345,7 +345,6 @@ /* * Replace the hop record contents */ - this->ignoreChanges = true; recipe->hops[recipe->hops_row].h_name = query.value(0).toString(); recipe->hops[recipe->hops_row].h_origin = query.value(1).toString(); recipe->hops[recipe->hops_row].h_alpha = query.value(2).toDouble(); @@ -390,7 +389,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 7, item); - this->ignoreChanges = false; calcIBUs(); is_changed(); } @@ -424,7 +422,6 @@ { qDebug() << "hop_useat_changed()" << recipe->hops_row << val; - this->ignoreChanges = true; recipe->hops[recipe->hops_row].h_useat = val; QTableWidgetItem *item = new QTableWidgetItem(h_useat[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); @@ -444,7 +441,6 @@ htimeEdit->setReadOnly(true); } - this->ignoreChanges = false; is_changed(); emit refreshAll(); } diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipeTab4.cpp --- a/src/EditRecipeTab4.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipeTab4.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -42,11 +42,15 @@ qDebug() << "refreshMiscs" << recipe->miscs.size(); std::sort(recipe->miscs.begin(), recipe->miscs.end(), misc_sort_test); - /* - * During filling the table turn off the cellChanged signal because every cell that is filled - * triggers the cellChanged signal. The QTableWidget has no better signal to use. - */ - this->ignoreChanges = true; + const QSignalBlocker blocker1(ui->bs_cacl2Edit); + const QSignalBlocker blocker2(ui->bs_caso4Edit); + const QSignalBlocker blocker3(ui->bs_mgso4Edit); + const QSignalBlocker blocker4(ui->bs_naclEdit); + const QSignalBlocker blocker5(ui->bs_mgcl2Edit); + const QSignalBlocker blocker6(ui->bs_nahco3Edit); + const QSignalBlocker blocker7(ui->bs_caco3Edit); + const QSignalBlocker blocker8(ui->mw_acidPick); + const QSignalBlocker blocker9(ui->mw_acidvolEdit); const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Delete"), tr("Edit") }); @@ -167,7 +171,6 @@ } } } - this->ignoreChanges = false; } @@ -245,9 +248,6 @@ */ void EditRecipe::set_brewing_salt(QString salt, double val) { - if (this->ignoreChanges) - return; - val = round(val * 100.0) / 100.0; qDebug() << "set_brewing_salt" << salt << val; brewing_salt_sub(salt, val); @@ -292,9 +292,7 @@ if (rc == QMessageBox::No) return; - this->ignoreChanges = true; recipe->miscs.removeAt(row); - this->ignoreChanges = false; is_changed(); emit refreshAll(); } @@ -305,7 +303,6 @@ QTableWidgetItem *item; qDebug() << "misc_amount_changed()" << recipe->miscs_row << val; - this->ignoreChanges = true; recipe->miscs[recipe->miscs_row].m_amount = val / 1000.0; if (recipe->miscs.at(recipe->miscs_row).m_amount_is_weight) { @@ -316,7 +313,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 4, item); - this->ignoreChanges = false; is_changed(); } @@ -327,7 +323,6 @@ qDebug() << "misc_time_changed()" << recipe->miscs_row << val; - this->ignoreChanges = true; if (recipe->miscs.at(recipe->miscs_row).m_use_use == 2) { // Boil recipe->miscs[recipe->miscs_row].m_time = val; item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); @@ -340,7 +335,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 3, item); - this->ignoreChanges = false; is_changed(); } @@ -376,7 +370,6 @@ /* * Replace the misc record contents */ - this->ignoreChanges = true; recipe->miscs[recipe->miscs_row].m_name = query.value(0).toString(); recipe->miscs[recipe->miscs_row].m_type = query.value(1).toInt(); recipe->miscs[recipe->miscs_row].m_use_use = query.value(2).toInt(); @@ -427,7 +420,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 4, item); - this->ignoreChanges = false; is_changed(); emit refreshAll(); } @@ -462,7 +454,6 @@ QTableWidgetItem *item; qDebug() << "misc_useat_changed" << val; - this->ignoreChanges = true; recipe->miscs[recipe->miscs_row].m_use_use = val; item = new QTableWidgetItem(m_uses[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); @@ -488,7 +479,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 3, item); - this->ignoreChanges = false; is_changed(); } @@ -646,7 +636,15 @@ if (recipe->miscs.size() == 0) return; - this->ignoreChanges = true; + const QSignalBlocker blocker1(ui->bs_cacl2Edit); + const QSignalBlocker blocker2(ui->bs_caso4Edit); + const QSignalBlocker blocker3(ui->bs_mgso4Edit); + const QSignalBlocker blocker4(ui->bs_naclEdit); + const QSignalBlocker blocker5(ui->bs_mgcl2Edit); + const QSignalBlocker blocker6(ui->bs_nahco3Edit); + const QSignalBlocker blocker7(ui->bs_caco3Edit); + const QSignalBlocker blocker9(ui->mw_acidvolEdit); + for (int i = 0; i < recipe->miscs.size(); i++) { amount = recipe->miscs.at(i).m_amount * factor; recipe->miscs[i].m_amount = amount; @@ -680,7 +678,6 @@ } } } - this->ignoreChanges = false; } diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipeTab5.cpp --- a/src/EditRecipeTab5.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipeTab5.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -38,12 +38,6 @@ qDebug() << "refreshYeasts" << recipe->yeasts.size(); std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test); - /* - * During filling the table turn off the cellChanged signal because every cell that is filled - * triggers the cellChanged signal. The QTableWidget has no better signal to use. - */ - this->ignoreChanges = true; - const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min. °C"), tr("Max. °C"), tr("Tol. %"), tr("Attn. %"), tr("Amount"), tr("Delete"), tr("Edit") }); @@ -125,8 +119,6 @@ pWidget->setLayout(pLayout); ui->yeastsTable->setCellWidget(i, 11, pWidget); } - - this->ignoreChanges = false; } @@ -271,9 +263,7 @@ if (rc == QMessageBox::No) return; - this->ignoreChanges = true; recipe->yeasts.removeAt(row); - this->ignoreChanges = false; is_changed(); emit refreshAll(); } @@ -284,14 +274,20 @@ QTableWidgetItem *item; qDebug() << "yeast_amount_changed()" << recipe->yeasts_row << val; - this->ignoreChanges = true; - recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.0; - item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); + if (recipe->yeasts.at(recipe->yeasts_row).y_form == 0) { + recipe->yeasts[recipe->yeasts_row].y_amount = val; + item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0')); + } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 1) { + recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.0; + item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0')); + } else { + recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.0; + item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0')); + } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); + ui->yeastsTable->setItem(recipe->yeasts_row, 9, item); - this->ignoreChanges = false; calcYeast(); is_changed(); } @@ -329,7 +325,6 @@ /* * Replace the yeast record contents */ - this->ignoreChanges = true; recipe->yeasts[recipe->yeasts_row].y_name = query.value(0).toString(); recipe->yeasts[recipe->yeasts_row].y_laboratory = query.value(1).toString(); recipe->yeasts[recipe->yeasts_row].y_product_id = query.value(2).toString(); @@ -360,6 +355,19 @@ ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_name); ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_laboratory); yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_product_id); + if (recipe->yeasts.at(recipe->yeasts_row).y_form == 0) { + yamountEdit->setDecimals(0); + yamountEdit->setSingleStep(1.0); + yamountLabel->setText(tr("Total packs:")); + } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 1) { + yamountEdit->setDecimals(1); + yamountEdit->setSingleStep(0.5); + yamountLabel->setText(tr("Amount in gr:")); + } else { + yamountEdit->setDecimals(1); + yamountEdit->setSingleStep(0.5); + yamountLabel->setText(tr("Amount in ml:")); + } ui->yeastsTable->setItem(recipe->yeasts_row, 0, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).y_name)); ui->yeastsTable->setItem(recipe->yeasts_row, 1, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).y_laboratory)); @@ -385,7 +393,6 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); - this->ignoreChanges = false; calcYeast(); is_changed(); } @@ -419,12 +426,10 @@ { qDebug() << "yeast_useat_changed()" << recipe->yeasts_row << val; - this->ignoreChanges = true; recipe->yeasts[recipe->yeasts_row].y_use = val; QTableWidgetItem *item = new QTableWidgetItem(y_use[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->yeastsTable->setItem(recipe->yeasts_row, 5, item); - this->ignoreChanges = false; is_changed(); emit refreshAll(); } @@ -474,11 +479,16 @@ instockLabel->setText(tr("In stock:")); instockLabel->setGeometry(QRect(525,100, 121, 20)); instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - QLabel *amountLabel = new QLabel(dialog); - amountLabel->setObjectName(QString::fromUtf8("amountLabel")); - amountLabel->setText(tr("Amount in gr:")); - amountLabel->setGeometry(QRect(10, 130, 141, 20)); - amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + yamountLabel = new QLabel(dialog); + yamountLabel->setObjectName(QString::fromUtf8("amountLabel")); + if (recipe->yeasts.at(recipe->yeasts_row).y_form == 0) + yamountLabel->setText(tr("Total packs:")); + else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 1) + yamountLabel->setText(tr("Amount in gr:")); + else + yamountLabel->setText(tr("Amount in ml:")); + yamountLabel->setGeometry(QRect(10, 130, 141, 20)); + yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); QLabel *useatLabel = new QLabel(dialog); useatLabel->setObjectName(QString::fromUtf8("useatLabel")); useatLabel->setText(tr("Use at:")); @@ -512,10 +522,20 @@ yamountEdit->setGeometry(QRect(160, 130, 121, 24)); yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); yamountEdit->setAccelerated(true); - yamountEdit->setDecimals(1); - yamountEdit->setMaximum(1000000.0); - yamountEdit->setSingleStep(0.5); - yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.0); + if (recipe->yeasts.at(recipe->yeasts_row).y_form == 0) { + yamountEdit->setDecimals(0); + yamountEdit->setSingleStep(1.0); + yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount); + } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 1) { + yamountEdit->setDecimals(1); + yamountEdit->setSingleStep(0.5); + yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.0); + } else { + yamountEdit->setDecimals(1); + yamountEdit->setSingleStep(0.5); + yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.0); + } + yamountEdit->setMaximum(1000000000.0); useatEdit = new QComboBox(dialog); useatEdit->setObjectName(QString::fromUtf8("useatEdit")); useatEdit->setGeometry(QRect(160, 160, 161, 23)); diff -r b5b2483f3a3f -r 58e4ce7dd217 src/EditRecipeTab7.cpp --- a/src/EditRecipeTab7.cpp Thu Apr 21 17:22:01 2022 +0200 +++ b/src/EditRecipeTab7.cpp Fri Apr 22 13:46:59 2022 +0200 @@ -226,13 +226,17 @@ bicarbonate += (ui->bs_nahco3Edit->value() * MMHCO3 / MMNaHCO3 * 1000 + ui->bs_caco3Edit->value() / 3 * MMHCO3 / MMCaCO3 * 1000) / liters; } + const QSignalBlocker blocker1(ui->mw_acidPick); + const QSignalBlocker blocker2(ui->mw_acidpercEdit); + const QSignalBlocker blocker3(ui->mw_acidvolEdit); + const QSignalBlocker blocker4(ui->wb_phEdit); + const QSignalBlocker blocker5(ui->mw_phEdit); + if (recipe->wa_acid_name < 0 || recipe->wa_acid_name >= my_acids.size()) { recipe->wa_acid_name = 0; recipe->wa_acid_perc = my_acids.at(0).AcidPrc; - this->ignoreChanges = true; ui->mw_acidPick->setCurrentIndex(0); ui->mw_acidpercEdit->setValue(my_acids.at(0).AcidPrc); - this->ignoreChanges = false; } AT = recipe->wa_acid_name; @@ -258,17 +262,13 @@ QString w = my_acids[AT].name_en + ' ' + my_acids[AT].name_nl; brewing_salt_sub(w, Acid); - this->ignoreChanges = true; ui->mw_acidvolEdit->setValue(Acid); - this->ignoreChanges = false; bicarbonate = bicarbonate - protonDeficit * frac / liters; total_alkalinity = bicarbonate * 50 / 61; } ph = TpH; - this->ignoreChanges = true; ui->wb_phEdit->setValue(ph); - this->ignoreChanges = false; recipe->mash_ph = ph; } else { // Manual /* @@ -306,10 +306,8 @@ bicarbonate = wg_bicarbonate - protonDeficit * frac / liters; total_alkalinity = bicarbonate * 50 / 61; ph = pHa; - this->ignoreChanges = true; ui->wb_phEdit->setValue(ph); ui->mw_phEdit->setValue(ph); - this->ignoreChanges = false; recipe->mash_ph = ph; } @@ -507,14 +505,13 @@ QSqlQuery query; qDebug() << "w1_name_changed" << val; + const QSignalBlocker blocker1(ui->w1_nameEdit); if (val == 0) { /* * If no water is selected, take the default water. */ - this->ignoreChanges = true; val = my_default_water; ui->w1_nameEdit->setCurrentIndex(val); - this->ignoreChanges = false; } query.prepare("SELECT * FROM inventory_waters ORDER BY record"); @@ -525,6 +522,7 @@ } qDebug() << "set water" << query.value(1).toString(); + recipe->w1_name = query.value(1).toString(); recipe->w1_calcium = query.value(3).toDouble(); recipe->w1_magnesium = query.value(8).toDouble(); recipe->w1_total_alkalinity = query.value(11).toDouble(); @@ -554,6 +552,7 @@ qDebug() << "w2_name_changed" << val; if (val == 0) { // Clear water 2. + recipe->w2_name = ""; recipe->w2_calcium = 0; recipe->w2_magnesium = 0; recipe->w2_total_alkalinity = 0; @@ -572,6 +571,7 @@ } qDebug() << "set water" << query.value(1).toString(); + recipe->w2_name = query.value(1).toString(); recipe->w2_calcium = query.value(3).toDouble(); recipe->w2_magnesium = query.value(8).toDouble(); recipe->w2_total_alkalinity = query.value(11).toDouble(); @@ -646,7 +646,9 @@ } } - this->ignoreChanges = true; + const QSignalBlocker blocker1(ui->w1_volEdit); + const QSignalBlocker blocker2(ui->w2_volEdit); + if (recipe->w2_amount == 0) { recipe->w1_amount = mash_infuse; ui->w1_volEdit->setValue(mash_infuse); @@ -660,7 +662,6 @@ } recipe->wg_amount = mash_infuse; ui->wg_volEdit->setValue(mash_infuse); - this->ignoreChanges = false; }