# HG changeset patch # User Michiel Broek # Date 1659291807 -7200 # Node ID d68826df8b63e75865dda98488dcb965a8131a4e # Parent bd20f8710f450ee19eddb0d436e1fac1e7d55593 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value. diff -r bd20f8710f45 -r d68826df8b63 src/EditProductExport.cpp --- a/src/EditProductExport.cpp Sun Jul 31 16:29:05 2022 +0200 +++ b/src/EditProductExport.cpp Sun Jul 31 20:23:27 2022 +0200 @@ -23,8 +23,8 @@ qDebug() << "export"; const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); - const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" }); - /* "Leaf Wet", "Cryo", "Extract" */ + const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet", "Pellet" }); + /* "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */ /* We use more hop forms then beerxml knows about, so we send known names */ /* instead of what we internally use. */ @@ -127,6 +127,9 @@ xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).beta, 'f', 1)); xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).hsi, 'f', 1)); xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).origin); + xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[product->hops.at(i).form]); + xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(product->hops.at(i).utilisation, 'f', 4)); + xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(product->hops.at(i).bu_factor, 'f', 1)); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // HOPS diff -r bd20f8710f45 -r d68826df8b63 src/EditRecipeExport.cpp --- a/src/EditRecipeExport.cpp Sun Jul 31 16:29:05 2022 +0200 +++ b/src/EditRecipeExport.cpp Sun Jul 31 20:23:27 2022 +0200 @@ -21,8 +21,8 @@ void EditRecipe::exportBeerXML() { const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); - const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" }); - /* "Leaf Wet", "Cryo", "Extract" */ + const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet", "Pellet" }); + /* "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */ /* We use more hop forms then beerxml knows about, so we send known names */ /* instead of what we internally use. */ @@ -119,6 +119,9 @@ xmlWriter->writeTextElement("BETA", QString::number(recipe->hops.at(i).beta, 'f', 1)); xmlWriter->writeTextElement("HSI", QString::number(recipe->hops.at(i).hsi, 'f', 1)); xmlWriter->writeTextElement("ORIGIN", recipe->hops.at(i).origin); + xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[recipe->hops.at(i).form]); + xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(recipe->hops.at(i).utilisation, 'f', 4)); + xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(recipe->hops.at(i).bu_factor, 'f', 1)); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // HOPS diff -r bd20f8710f45 -r d68826df8b63 src/database/db_product.cpp --- a/src/database/db_product.cpp Sun Jul 31 16:29:05 2022 +0200 +++ b/src/database/db_product.cpp Sun Jul 31 20:23:27 2022 +0200 @@ -378,7 +378,10 @@ h.utilisation = yquery.value("utilisation").toDouble(); if (h.bu_factor == 0) h.bu_factor = yquery.value("bu_factor").toDouble(); - } + } else { + h.utilisation = my_ut_pellet; + h.bu_factor = 1.0; + } prod->hops.append(h); } qDebug() << "hops" << prod->hops.size(); diff -r bd20f8710f45 -r d68826df8b63 src/database/db_recipe.cpp --- a/src/database/db_recipe.cpp Sun Jul 31 16:29:05 2022 +0200 +++ b/src/database/db_recipe.cpp Sun Jul 31 20:23:27 2022 +0200 @@ -220,6 +220,9 @@ if (yquery.first()) { h.utilisation = yquery.value("utilisation").toDouble(); h.bu_factor = yquery.value("bu_factor").toDouble(); + } else { + h.utilisation = my_ut_pellet; + h.bu_factor = 1.0; } } reci->hops.append(h);