src/EditRecipeExport.cpp

changeset 302
2e8462219332
parent 300
2a97905cb637
child 304
aa8d421bfc24
--- a/src/EditRecipeExport.cpp	Mon Jun 20 19:55:23 2022 +0200
+++ b/src/EditRecipeExport.cpp	Tue Jun 21 09:08:59 2022 +0200
@@ -20,24 +20,15 @@
 
 void EditRecipe::exportBeerXML()
 {
-    const QStringList styletype({ "Lager", "Ale", "Mead", "Wheat", "Mixed", "Cider" });
-    const QStringList recipetypes({ "Extract", "Partial Mash", "All Grain" });
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
     const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
-    const QStringList hop_types({ "Bittering", "Aroma", "Both" });
     const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" });
     /*                                                    "Leaf Wet", "Cryo", "Extract" */
     /*  We use more hop forms then beerxml knows about, so we send known names */
     /*  instead of what we internally use. */
     const QStringList hop_use({ "Mash", "First wort", "Boil", "Aroma", "Whirlpool", "Dry hop", "Dry hop" });
-    const QStringList fermentable_type({ "Grain", "Sugar", "Extract", "Dry extract", "Adjunct" });
-    const QStringList fermentable_graintype({ "Base", "Roast", "Crystal", "Kilned", "Sour malt", "Special", "No malt" });
     const QStringList yeast_type({ "Lager", "Ale", "Wheat", "Wine", "Champagne", "Other", "Other", "Other", "Other", "Other" });
     const QStringList yeast_form({ "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dry" });
-    const QStringList yeast_use({ "Primary", "Secondary", "Tertiary", "Bottle" });
-    const QStringList misc_type({ "Spice", "Herb", "Flavor", "Fining", "Water agent", "Yeast nutrient", "Other" });
-    const QStringList misc_use({ "Starter", "Mash", "Boil", "Primary", "Secondary", "Bottling" });
-    const QStringList step_type({ "Infusion", "Temperature", "Decoction" });
 
     QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/" + recipe->name + ".xml", tr("Files (*.xml)"));
     if (fileName == 0) {
@@ -63,7 +54,7 @@
     xmlWriter->writeTextElement("NAME", recipe->name);
     if (recipe->notes != "")
 	xmlWriter->writeTextElement("NOTES", recipe->notes);
-    xmlWriter->writeTextElement("TYPE", recipetypes[recipe->type]);
+    xmlWriter->writeTextElement("TYPE", g_recipe_types[recipe->type]);
     xmlWriter->writeTextElement("BREWER", "Anonymous");
     xmlWriter->writeTextElement("BATCH_SIZE", QString::number(recipe->batch_size, 'f', 4));
     xmlWriter->writeTextElement("BOIL_SIZE", QString::number(recipe->boil_size, 'f', 4));
@@ -89,7 +80,7 @@
 	xmlWriter->writeTextElement("CATEGORY_NUMBER", QString::number(recipe->st_category_number, 'f', 0));
 	xmlWriter->writeTextElement("STYLE_LETTER", recipe->st_letter);
 	xmlWriter->writeTextElement("STYLE_GUIDE", recipe->st_guide);
-	xmlWriter->writeTextElement("TYPE", styletype[recipe->st_type]);
+	xmlWriter->writeTextElement("TYPE", g_style_types[recipe->st_type]);
 	xmlWriter->writeTextElement("OG_MIN", QString::number(recipe->st_og_min, 'f', 3));
 	xmlWriter->writeTextElement("OG_MAX", QString::number(recipe->st_og_max, 'f', 3));
 	xmlWriter->writeTextElement("FG_MIN", QString::number(recipe->st_fg_min, 'f', 3));
@@ -121,7 +112,7 @@
 	xmlWriter->writeTextElement("AMOUNT", QString::number(recipe->hops.at(i).amount, 'f', 4));
 	xmlWriter->writeTextElement("USE", hop_use[recipe->hops.at(i).useat]);
 	xmlWriter->writeTextElement("TIME", QString::number(recipe->hops.at(i).time, 'f', 0));
-	xmlWriter->writeTextElement("TYPE", hop_types[recipe->hops.at(i).type]);
+	xmlWriter->writeTextElement("TYPE", g_hop_types[recipe->hops.at(i).type]);
 	xmlWriter->writeTextElement("FORM", hop_forms[recipe->hops.at(i).form]);
 	xmlWriter->writeTextElement("BETA", QString::number(recipe->hops.at(i).beta, 'f', 1));
 	xmlWriter->writeTextElement("HSI", QString::number(recipe->hops.at(i).hsi, 'f', 1));
@@ -135,7 +126,7 @@
         xmlWriter->writeStartElement("FERMENTABLE");
         xmlWriter->writeTextElement("VERSION", "1");
 	xmlWriter->writeTextElement("NAME", recipe->fermentables.at(i).name);
-	xmlWriter->writeTextElement("TYPE", fermentable_type[recipe->fermentables.at(i).type]);
+	xmlWriter->writeTextElement("TYPE", g_fermentable_types[recipe->fermentables.at(i).type]);
 	xmlWriter->writeTextElement("AMOUNT", QString::number(recipe->fermentables.at(i).amount, 'f', 4));
 	xmlWriter->writeTextElement("YIELD", QString::number(recipe->fermentables.at(i).yield, 'f', 1));
 	xmlWriter->writeTextElement("COLOR", QString::number(Utils::ebc_to_srm(recipe->fermentables.at(i).color), 'f', 1));
@@ -153,7 +144,7 @@
 	if (recipe->fermentables.at(i).max_in_batch)
 	    xmlWriter->writeTextElement("MAX_IN_BATCH", QString::number(recipe->fermentables.at(i).max_in_batch, 'f', 1));
 	xmlWriter->writeTextElement("RECOMMEND_MASH", recipe->fermentables.at(i).recommend_mash ? "TRUE":"FALSE");
-	xmlWriter->writeTextElement("GRAINTYPE", fermentable_graintype[recipe->fermentables.at(i).graintype]);
+	xmlWriter->writeTextElement("GRAINTYPE", g_fermentable_graintypes[recipe->fermentables.at(i).graintype]);
 	xmlWriter->writeEndElement();
     }
     xmlWriter->writeEndElement();	// FERMENTABLES
@@ -163,10 +154,10 @@
         xmlWriter->writeStartElement("MISC");
         xmlWriter->writeTextElement("VERSION", "1");
         xmlWriter->writeTextElement("NAME", recipe->miscs.at(i).name);
-	xmlWriter->writeTextElement("TYPE", misc_type[recipe->miscs.at(i).type]);
+	xmlWriter->writeTextElement("TYPE", g_misc_types[recipe->miscs.at(i).type]);
 	xmlWriter->writeTextElement("AMOUNT", QString::number(recipe->miscs.at(i).amount, 'f', 5));
 	xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", recipe->miscs.at(i).amount_is_weight ? "TRUE":"FALSE");
-	xmlWriter->writeTextElement("USE", misc_use[recipe->miscs.at(i).use_use]);
+	xmlWriter->writeTextElement("USE", g_misc_uses[recipe->miscs.at(i).use_use]);
 	xmlWriter->writeTextElement("TIME", QString::number(recipe->miscs.at(i).time, 'f', 0));
 	xmlWriter->writeEndElement();
     }
@@ -235,7 +226,7 @@
 	xmlWriter->writeStartElement("MASH_STEP");
 	xmlWriter->writeTextElement("VERSION", "1");
 	xmlWriter->writeTextElement("NAME", recipe->mashs.at(i).step_name);
-	xmlWriter->writeTextElement("TYPE", step_type[recipe->mashs.at(i).step_type]);
+	xmlWriter->writeTextElement("TYPE", g_step_types[recipe->mashs.at(i).step_type]);
 	if (recipe->mashs.at(i).step_type == 0) {
 	    xmlWriter->writeTextElement("INFUSE_AMOUNT", QString::number(recipe->mashs.at(i).step_infuse_amount, 'f', 3));
 	    xmlWriter->writeTextElement("INFUSE_TEMP", QString::number(recipe->mashs.at(i).step_infuse_temp, 'f', 3));
@@ -442,17 +433,8 @@
 
 void EditRecipe::toforumRecipe()
 {
-    const QStringList recipetypes({ "Extract", "Partial Mash", "All Grain" });
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
     const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
-    const QStringList fermentable_added({ "Maischen", "Koken", "Hoofd/nagisting", "Lageren", "Bottelen", "Fusten" });
-    const QStringList hop_forms({ "Pellet", "Plug", "Bloemen", "Verse hop", "Cryo", "Extract" });
-    const QStringList hop_use({ "Maischen", "First wort", "Koken", "Vlamuit", "Whirlpool", "Drooghop", "Bottelen" });
-    const QStringList misc_type({ "Spice", "Herb", "Smaakstof", "Klaren", "Brouwzout", "Gist voeding", "Overig" });
-    const QStringList misc_use({ "Starter", "Maischen", "Koken", "Hoofdgisting", "Nagisting", "Bottelen" });
-    const QStringList yeast_form({ "Vloeibaar", "Droog", "Schuine buis", "Opkweek", "Ingevroren", "Flesbodem", "Gedroogd" });
-    const QStringList yeast_use({ "Hoofdgisting", "Nagisting", "Lageren", "Bottelen", "Fusten" });
-    const QStringList step_type({ "Infusie", "Verwarmen", "Decoctie" });
 
     QString memo = QString("[u][b]BMSapp v");
     memo.append(VERSIONSTRING);	// For some stupid reason this must be on it's own.
@@ -461,7 +443,7 @@
     memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
     memo.append("[row][data]Bier naam[/data][data]" + recipe->name + "[/data][/row]\n");
     memo.append("[row][data]Bier stijl[/data][data]" + recipe->st_name + "[/data][/row]\n");
-    memo.append("[row][data]Recept type[/data][data]" + recipetypes[recipe->type] + "[/data][/row]\n");
+    memo.append("[row][data]Recept type[/data][data]" + QCoreApplication::translate("RecipeType", g_recipe_types[recipe->type]) + "[/data][/row]\n");
     memo.append("[row][data]Batch grootte[/data][data]" + QString::number(recipe->batch_size, 'f', 1) + " L[/data][/row]\n");
     memo.append("[row][data]Kooktijd[/data][data]" + QString::number(recipe->boil_time, 'f', 0) + " minuten[/data][/row]\n");
     memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(recipe->efficiency, 'f', 1) + "%[/data][/row]\n");
@@ -480,7 +462,7 @@
 	memo.append("[data]" + QString::number(recipe->fermentables.at(i).color) + "[/data]");
 	memo.append("[data]" + QString::number(recipe->fermentables.at(i).amount, 'f', 3) + "[/data]");
 	memo.append("[data]" + QString::number(recipe->fermentables.at(i).percentage, 'f', 1) + "[/data]");
-	memo.append("[data]" + fermentable_added[recipe->fermentables.at(i).added] + "[/data][/row]\n");
+	memo.append("[data]" + QCoreApplication::translate("FermentableAdded", g_fermentable_added[recipe->fermentables.at(i).added]) + "[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
 
@@ -492,16 +474,16 @@
 			recipe->hops.at(i).amount, recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method,
 			0, recipe->hops.at(i).time, 0, recipe->boil_time);
 	memo.append("[row][data]" + recipe->hops.at(i).name + " (" + recipe->hops.at(i).origin + ")[/data]");
-	memo.append("[data]" + hop_forms[recipe->hops.at(i).form] + "[/data]");
+	memo.append("[data]" + QCoreApplication::translate("HopForm", g_hop_forms[recipe->hops.at(i).form]) + "[/data]");
 	memo.append("[data]" + QString::number(recipe->hops.at(i).alpha, 'f', 1) + "[/data]");
 	memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]");
 	memo.append("[data]" + QString::number(recipe->hops.at(i).amount * 1000, 'f', 2) + "[/data]");
 	if (recipe->hops.at(i).useat == HOP_USEAT_BOIL || recipe->hops.at(i).useat == HOP_USEAT_WHIRLPOOL)
-	    memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + " " + QString::number(recipe->hops.at(i).time) + " minuten[/data][/row]\n");
+	    memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[recipe->hops.at(i).useat]) + " " + QString::number(recipe->hops.at(i).time) + " minuten[/data][/row]\n");
 	else if (recipe->hops.at(i).useat == HOP_USEAT_DRY_HOP)
-	    memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + " " + QString::number(recipe->hops.at(i).time / 1440) + " dagen[/data][/row]\n");
+	    memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[recipe->hops.at(i).useat]) + " " + QString::number(recipe->hops.at(i).time / 1440) + " dagen[/data][/row]\n");
 	else
-	    memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + "[/data][/row]\n");
+	    memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[recipe->hops.at(i).useat]) + "[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
 
@@ -510,11 +492,11 @@
     memo.append("[head]Specerij, kruid, brouwzout[/head][head]Type grondstof[/head][head]Gebruik tijdens[/head][head]Hoeveel[/head]\n");
     for (int i = 0; i < recipe->miscs.size(); i++) {
 	memo.append("[row][data]" + recipe->miscs.at(i).name + "[/data]");
-	memo.append("[data]" + misc_type[recipe->miscs.at(i).type] + "[/data]");
+	memo.append("[data]" + QCoreApplication::translate("MiscType", g_misc_types[recipe->miscs.at(i).type]) + "[/data]");
 	if (recipe->miscs.at(i).use_use == MISC_USES_BOIL)
-	    memo.append("[data]" + misc_use[recipe->miscs.at(i).use_use] + " " + QString::number(recipe->miscs.at(i).time) + " min[/data]");
+	    memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[recipe->miscs.at(i).use_use]) + " " + QString::number(recipe->miscs.at(i).time) + " min[/data]");
 	else
-	    memo.append("[data]" + misc_use[recipe->miscs.at(i).use_use] + "[/data]");
+	    memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[recipe->miscs.at(i).use_use]) + "[/data]");
 	memo.append("[data]"+QString::number(recipe->miscs.at(i).amount * 1000, 'f', 2)+((recipe->miscs.at(i).amount_is_weight)?" gr":" ml")+"[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
@@ -525,8 +507,8 @@
     for (int i = 0; i < recipe->yeasts.size(); i++) {
 	memo.append("[row][data]" + recipe->yeasts.at(i).laboratory + " " + recipe->yeasts.at(i).product_id + "[/data]");
 	memo.append("[data]" + recipe->yeasts.at(i).name + "[/data]");
-	memo.append("[data]" + yeast_use[recipe->yeasts.at(i).use] + "[/data]");
-	memo.append("[data]" + yeast_form[recipe->yeasts.at(i).form] + "[/data]");
+	memo.append("[data]" + QCoreApplication::translate("YeastUse", g_yeast_use[recipe->yeasts.at(i).use]) + "[/data]");
+	memo.append("[data]" + QCoreApplication::translate("YeastForm", g_yeast_forms[recipe->yeasts.at(i).form]) + "[/data]");
 	if (recipe->yeasts.at(i).form == YEAST_FORMS_LIQUID)
 	    memo.append("[data]" + QString::number(recipe->yeasts.at(i).amount, 'f', 0) + " pak[/data][/row]\n");
 	else if (recipe->yeasts.at(i).form == YEAST_FORMS_DRY || recipe->yeasts.at(i).form == YEAST_FORMS_DRIED)
@@ -542,9 +524,9 @@
     for (int i = 0; i < recipe->mashs.size(); i++) {
 	memo.append("[row][data]" + recipe->mashs.at(i).step_name + "[/data]");
 	if (recipe->mashs.at(i).step_type != 1)
-	    memo.append("[data]" + step_type[recipe->mashs.at(i).step_type]+" "+QString::number(recipe->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]");
+	    memo.append("[data]" + QCoreApplication::translate("StepType", g_step_types[recipe->mashs.at(i).step_type])+" "+QString::number(recipe->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]");
 	else
-	    memo.append("[data]" + step_type[recipe->mashs.at(i).step_type] + "[/data]");
+	    memo.append("[data]" + QCoreApplication::translate("StepType", g_step_types[recipe->mashs.at(i).step_type]) + "[/data]");
 	memo.append("[data]" + QString::number(recipe->mashs.at(i).step_temp, 'f', 1) + " °C[/data]");
 	memo.append("[data]" + QString::number(recipe->mashs.at(i).step_time, 'f', 0) + " min[/data]");
 	memo.append("[data]" + QString::number(recipe->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n");

mercurial