# HG changeset patch # User Michiel Broek # Date 1675347798 -3600 # Node ID eb0a5f132ea931a47adcd7ed3a26eafe6aeaac4c # Parent e13763ec829fef364ae18ea446cb807dafcce316 Added default load yeastpacks. Added yeast_package_changed signal. diff -r e13763ec829f -r eb0a5f132ea9 src/EditProduct.h --- a/src/EditProduct.h Tue Jan 31 16:24:11 2023 +0100 +++ b/src/EditProduct.h Thu Feb 02 15:23:18 2023 +0100 @@ -103,6 +103,7 @@ void yeast_pitchrate_button_clicked(); void yeast_retry_button_clicked(); void yeast_amount_changed(double val); + void yeast_package_changed(int val); void yeast_select_changed(int val); void yeast_instock_changed(bool val); void yeast_useat_changed(int val); @@ -340,6 +341,7 @@ void calcViability(); void calcYeast(); void adjustYeasts(double factor); + void yeast_load_packages(QString laboratory, int form); double infusionVol(double step_infused, double step_mashkg, double infuse_temp, double step_temp, double last_temp); double decoctionVol(double step_volume, double step_temp, double prev_temp); void calcMash(); diff -r e13763ec829f -r eb0a5f132ea9 src/EditProductTab6.cpp --- a/src/EditProductTab6.cpp Tue Jan 31 16:24:11 2023 +0100 +++ b/src/EditProductTab6.cpp Thu Feb 02 15:23:18 2023 +0100 @@ -590,7 +590,12 @@ for (int i = 0; i < product->yeasts.size(); i++) { if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) { - if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) { + qDebug() << "calcViability()" << i << product->yeasts.at(i).yp_uuid << product->yeasts.at(i).yp_package; + if (! product->yeasts.at(i).yp_uuid.isNull() && (product->yeasts.at(i).yp_uuid.length() == 36)) { + qDebug() << " valid package vpm:" << product->yeasts.at(i).yp_viability << product->yeasts.at(i).yp_max; + vpm = product->yeasts.at(i).yp_viability; + max = product->yeasts.at(i).yp_max; + } else if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) { // Fallback to hardcoded values. vpm = 0.80; max = 97; if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch @@ -954,9 +959,79 @@ } +void EditProduct::yeast_load_packages(QString laboratory, int form) +{ + QSqlQuery query; + + /* + * Clear package and rebuild package select table. + */ + this->ypackageEdit->setCurrentIndex(-1); + this->ypackageEdit->clear(); + this->ypackageEdit->addItem(""); // Start with empty value + query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); + query.bindValue(":laboratory", laboratory); + query.bindValue(":form", form); + qDebug() << " search" << laboratory << form; + query.exec(); + while (query.next()) { + this->ypackageEdit->addItem(query.value("laboratory").toString()+" - "+query.value("package").toString()); + qDebug() << " add package" << query.value("laboratory").toString() << query.value("package").toString(); + } +} + + +void EditProduct::yeast_package_changed(int val) +{ + QSqlQuery query; + int index = 0; + +#ifdef DEBUG_YEAST + qDebug() << "yeast_package_changed()" << product->yeasts_row << val; +#endif + + /* + * Scan the packages for result number 'val' + */ + query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); + query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory); + query.bindValue(":form", product->yeasts.at(product->yeasts_row).form); + qDebug() << " search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form; + query.exec(); + while (query.next()) { + index++; + if (index == val) { + qDebug() << " result" << index << query.value("package").toString(); + product->yeasts[product->yeasts_row].yp_uuid = query.value("uuid").toString(); + product->yeasts[product->yeasts_row].yp_package = query.value("package").toString(); + product->yeasts[product->yeasts_row].yp_cells = query.value("cells").toDouble(); + product->yeasts[product->yeasts_row].yp_viability = query.value("viability").toDouble(); + product->yeasts[product->yeasts_row].yp_max = query.value("max").toInt(); + product->yeasts[product->yeasts_row].yp_size = query.value("size").toDouble(); + is_changed(); + return; + } + } + if (! product->yeasts[product->yeasts_row].yp_uuid.isNull()) { + /* + * Clear package + */ + product->yeasts[product->yeasts_row].yp_uuid = QString(); + product->yeasts[product->yeasts_row].yp_package = QString(); + product->yeasts[product->yeasts_row].yp_cells = product->yeasts[product->yeasts_row].cells; + product->yeasts[product->yeasts_row].yp_viability = 0.99; + product->yeasts[product->yeasts_row].yp_max = 100; + product->yeasts[product->yeasts_row].yp_size = 0.01; + is_changed(); + qDebug() << " cleared old yp_xxx data"; + } + qDebug() << " result not found"; +} + + void EditProduct::yeast_select_changed(int val) { - QSqlQuery query, query1; + QSqlQuery query; bool instock = yinstockEdit->isChecked(); QString w; QTableWidgetItem *item; @@ -1052,18 +1127,7 @@ /* * Clear package and rebuild package select table. */ - this->ypackageEdit->setCurrentIndex(-1); - this->ypackageEdit->clear(); - this->ypackageEdit->addItem(""); // Start with empty value - query1.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); - query1.bindValue(":laboratory", query.value("laboratory").toString()); - query1.bindValue(":form", query.value("form").toInt()); - qDebug() << " search" << query.value("laboratory").toString() << query.value("form").toInt(); - query1.exec(); - while (query1.next()) { - this->ypackageEdit->addItem(query1.value("laboratory").toString()+" - "+query1.value("package").toString()); - qDebug() << " add package" << query1.value("laboratory").toString() << query1.value("package").toString(); - } + yeast_load_packages(query.value("laboratory").toString(), query.value("form").toInt()); ui->yeastsTable->setItem(product->yeasts_row, 0, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).name)); ui->yeastsTable->setItem(product->yeasts_row, 1, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).laboratory)); @@ -1298,8 +1362,25 @@ useatEdit->setCurrentIndex(product->yeasts.at(product->yeasts_row).use); yeast_instock_changed(true); + yeast_load_packages(product->yeasts.at(product->yeasts_row).laboratory, product->yeasts.at(product->yeasts_row).form); + + int index = -1; + if (! product->yeasts.at(product->yeasts_row).yp_uuid.isNull() && (product->yeasts.at(product->yeasts_row).yp_uuid.length() == 36)) { + query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); + query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory); + query.bindValue(":form", product->yeasts.at(product->yeasts_row).form); + qDebug() << " search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form; + query.exec(); + while (query.next()) { + index++; + if (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid) + break; + } + qDebug() << " result" << index << (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid); + } connect(yselectEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed); + connect(ypackageEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_package_changed); connect(yamountEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::yeast_amount_changed); connect(useatEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_useat_changed); connect(yinstockEdit, &QCheckBox::stateChanged, this, &EditProduct::yeast_instock_changed); @@ -1318,6 +1399,7 @@ } disconnect(yselectEdit, nullptr, nullptr, nullptr); + disconnect(ypackageEdit, nullptr, nullptr, nullptr); disconnect(yamountEdit, nullptr, nullptr, nullptr); disconnect(useatEdit, nullptr, nullptr, nullptr); disconnect(yinstockEdit, nullptr, nullptr, nullptr); diff -r e13763ec829f -r eb0a5f132ea9 translations/bmsapp_en.ts --- a/translations/bmsapp_en.ts Tue Jan 31 16:24:11 2023 +0100 +++ b/translations/bmsapp_en.ts Thu Feb 02 15:23:18 2023 +0100 @@ -4330,7 +4330,7 @@ - + @@ -4366,7 +4366,7 @@ - + Use at: @@ -4380,7 +4380,7 @@ - + In stock: @@ -4522,8 +4522,8 @@ - - + + Amount in gr: @@ -4562,8 +4562,8 @@ - - + + Amount in ml: @@ -4574,13 +4574,13 @@ - + Primary - + Secondary @@ -4666,114 +4666,114 @@ - + BMSapp - Pitchrate - + Beer pitch type: - + 0.075 Real Kveik - + 0.75 Ale, upto 1.060 - + 1.0 Ale, above 1.060 - + 1.5 Lager, upto 1.060 - + 2.0 Lager, above 1.060 - + Retry starter - + Retry to automatic create starter steps - - Start step type: - - - + Start step type: + + + + Starter step volume: - + Stirred - + Shaken - + Simple - + Delete yeast - - + + Total packs: - + Yeast name: - - + + Laboratory: - + Select yeast: - + Select package: - + Tertiary - + Bottle diff -r e13763ec829f -r eb0a5f132ea9 translations/bmsapp_nl.ts --- a/translations/bmsapp_nl.ts Tue Jan 31 16:24:11 2023 +0100 +++ b/translations/bmsapp_nl.ts Thu Feb 02 15:23:18 2023 +0100 @@ -4846,7 +4846,7 @@ - + @@ -4882,7 +4882,7 @@ - + Use at: Toevoegen bij: @@ -4896,7 +4896,7 @@ - + In stock: In voorraad: @@ -5038,8 +5038,8 @@ - - + + Amount in gr: Gewicht in gr: @@ -5097,8 +5097,8 @@ - - + + Amount in ml: Hoeveelheid in ml: @@ -5109,13 +5109,13 @@ - + Primary Hoofdgisting - + Secondary Nagisting/lagering @@ -5201,114 +5201,114 @@ Groeifactor - + BMSapp - Pitchrate BMSapp - Gist enten - + Beer pitch type: Biergist nodig: - + 0.075 Real Kveik 0,075 Echte Kveik - + 0.75 Ale, upto 1.060 0,75 Bovengist tot 1.060 - + 1.0 Ale, above 1.060 1,0 Bovengist hoger 1.060 - + 1.5 Lager, upto 1.060 1,5 Ondergist tot 1.060 - + 2.0 Lager, above 1.060 2,0 Ondergist hoger 1.060 - + Retry starter Ververs starter - + Retry to automatic create starter steps Ververs de starter stappen automatisch - - Start step type: - Starter stap type: - - + Start step type: + Starter stap type: + + + Starter step volume: Starter stap volume: - + Stirred Geroerd - + Shaken Geschud - + Simple Simpel - + Delete yeast Verwijder gist - - + + Total packs: Aantal pakken: - + Yeast name: Gist naam: - - + + Laboratory: Laboratorium: - + Select yeast: Kies gist: - + Select package: - + Tertiary Lageren - + Bottle Bottelen