src/EditProductExport.cpp

changeset 302
2e8462219332
parent 301
fe6346211b5b
child 304
aa8d421bfc24
--- a/src/EditProductExport.cpp	Mon Jun 20 19:55:23 2022 +0200
+++ b/src/EditProductExport.cpp	Tue Jun 21 09:08:59 2022 +0200
@@ -22,24 +22,15 @@
 {
     qDebug() << "export";
 
-    const QStringList styletype({ "Lager", "Ale", "Mead", "Wheat", "Mixed", "Cider" });
-    const QStringList producttypes({ "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" });	// tetra == 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() + "/" + product->code + " " + product->name + ".xml", tr("Files (*.xml)"));
@@ -65,7 +56,7 @@
     xmlWriter->writeTextElement("NAME", product->name);
     if (product->notes != "")
 	xmlWriter->writeTextElement("NOTES", product->notes);
-    xmlWriter->writeTextElement("TYPE", producttypes[product->type]);
+    xmlWriter->writeTextElement("TYPE", g_recipe_types[product->type]);
     xmlWriter->writeTextElement("BREWER", "Anonymous");
     xmlWriter->writeTextElement("BATCH_SIZE", QString::number(product->batch_size, 'f', 4));
     xmlWriter->writeTextElement("BOIL_SIZE", QString::number(product->boil_size, 'f', 4));
@@ -96,7 +87,7 @@
 	xmlWriter->writeTextElement("CATEGORY_NUMBER", QString::number(product->st_category_number, 'f', 0));
 	xmlWriter->writeTextElement("STYLE_LETTER", product->st_letter);
 	xmlWriter->writeTextElement("STYLE_GUIDE", product->st_guide);
-	xmlWriter->writeTextElement("TYPE", styletype[product->st_type]);
+	xmlWriter->writeTextElement("TYPE", g_style_types[product->st_type]);
 	xmlWriter->writeTextElement("OG_MIN", QString::number(product->st_og_min, 'f', 3));
 	xmlWriter->writeTextElement("OG_MAX", QString::number(product->st_og_max, 'f', 3));
 	xmlWriter->writeTextElement("FG_MIN", QString::number(product->st_fg_min, 'f', 3));
@@ -129,7 +120,7 @@
 	xmlWriter->writeTextElement("AMOUNT", QString::number(product->hops.at(i).amount, 'f', 4));
 	xmlWriter->writeTextElement("USE", hop_use[product->hops.at(i).useat]);
 	xmlWriter->writeTextElement("TIME", QString::number(product->hops.at(i).time, 'f', 0));
-	xmlWriter->writeTextElement("TYPE", hop_types[product->hops.at(i).type]);
+	xmlWriter->writeTextElement("TYPE", g_hop_types[product->hops.at(i).type]);
 	xmlWriter->writeTextElement("FORM", hop_forms[product->hops.at(i).form]);
 	xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).beta, 'f', 1));
 	xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).hsi, 'f', 1));
@@ -144,7 +135,7 @@
             xmlWriter->writeStartElement("FERMENTABLE");
             xmlWriter->writeTextElement("VERSION", "1");
 	    xmlWriter->writeTextElement("NAME", product->fermentables.at(i).name);
-	    xmlWriter->writeTextElement("TYPE", fermentable_type[product->fermentables.at(i).type]);
+	    xmlWriter->writeTextElement("TYPE", g_fermentable_types[product->fermentables.at(i).type]);
 	    xmlWriter->writeTextElement("AMOUNT", QString::number(product->fermentables.at(i).amount, 'f', 4));
 	    xmlWriter->writeTextElement("YIELD", QString::number(product->fermentables.at(i).yield, 'f', 1));
 	    xmlWriter->writeTextElement("COLOR", QString::number(Utils::ebc_to_srm(product->fermentables.at(i).color), 'f', 1));
@@ -162,7 +153,7 @@
 	    if (product->fermentables.at(i).max_in_batch)
 	    	xmlWriter->writeTextElement("MAX_IN_BATCH", QString::number(product->fermentables.at(i).max_in_batch, 'f', 1));
 	    xmlWriter->writeTextElement("RECOMMEND_MASH", product->fermentables.at(i).recommend_mash ? "TRUE":"FALSE");
-	    xmlWriter->writeTextElement("GRAINTYPE", fermentable_graintype[product->fermentables.at(i).graintype]);
+	    xmlWriter->writeTextElement("GRAINTYPE", g_fermentable_graintypes[product->fermentables.at(i).graintype]);
 	    xmlWriter->writeEndElement();
 	}
     }
@@ -173,10 +164,10 @@
         xmlWriter->writeStartElement("MISC");
         xmlWriter->writeTextElement("VERSION", "1");
         xmlWriter->writeTextElement("NAME", product->miscs.at(i).name);
-	xmlWriter->writeTextElement("TYPE", misc_type[product->miscs.at(i).type]);
+	xmlWriter->writeTextElement("TYPE", g_misc_types[product->miscs.at(i).type]);
 	xmlWriter->writeTextElement("AMOUNT", QString::number(product->miscs.at(i).amount, 'f', 5));
 	xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", product->miscs.at(i).amount_is_weight ? "TRUE":"FALSE");
-	xmlWriter->writeTextElement("USE", misc_use[product->miscs.at(i).use_use]);
+	xmlWriter->writeTextElement("USE", g_misc_uses[product->miscs.at(i).use_use]);
 	xmlWriter->writeTextElement("TIME", QString::number(product->miscs.at(i).time, 'f', 0));
 	xmlWriter->writeEndElement();
     }
@@ -245,7 +236,7 @@
 	xmlWriter->writeStartElement("MASH_STEP");
 	xmlWriter->writeTextElement("VERSION", "1");
 	xmlWriter->writeTextElement("NAME", product->mashs.at(i).step_name);
-	xmlWriter->writeTextElement("TYPE", step_type[product->mashs.at(i).step_type]);
+	xmlWriter->writeTextElement("TYPE", g_step_types[product->mashs.at(i).step_type]);
 	if (product->mashs.at(i).step_type == 0) {
 	    xmlWriter->writeTextElement("INFUSE_AMOUNT", QString::number(product->mashs.at(i).step_infuse_amount, 'f', 3));
 	    xmlWriter->writeTextElement("INFUSE_TEMP", QString::number(product->mashs.at(i).step_infuse_temp, 'f', 3));
@@ -425,17 +416,8 @@
 
 void EditProduct::toforumProduct()
 {
-    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.
@@ -444,7 +426,7 @@
     memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
     memo.append("[row][data]Bier naam[/data][data]" + product->name + "[/data][/row]\n");
     memo.append("[row][data]Bier stijl[/data][data]" + product->st_name + "[/data][/row]\n");
-    memo.append("[row][data]Recept type[/data][data]" + recipetypes[product->type] + "[/data][/row]\n");
+    memo.append("[row][data]Recept type[/data][data]" + QCoreApplication::translate("RecipeType", g_recipe_types[product->type]) + "[/data][/row]\n");
     memo.append("[row][data]Batch grootte[/data][data]" + QString::number(product->batch_size, 'f', 1) + " L[/data][/row]\n");
     memo.append("[row][data]Kooktijd[/data][data]" + QString::number(product->boil_time, 'f', 0) + " minuten[/data][/row]\n");
     memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(product->efficiency, 'f', 1) + "%[/data][/row]\n");
@@ -463,7 +445,7 @@
         memo.append("[data]" + QString::number(product->fermentables.at(i).color) + "[/data]");
         memo.append("[data]" + QString::number(product->fermentables.at(i).amount, 'f', 3) + "[/data]");
         memo.append("[data]" + QString::number(product->fermentables.at(i).percentage, 'f', 1) + "[/data]");
-        memo.append("[data]" + fermentable_added[product->fermentables.at(i).added] + "[/data][/row]\n");
+        memo.append("[data]" + QCoreApplication::translate("FermentableAdded", g_fermentable_added[product->fermentables.at(i).added]) + "[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
 
@@ -475,16 +457,16 @@
                         product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
                         product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
         memo.append("[row][data]" + product->hops.at(i).name + " (" + product->hops.at(i).origin + ")[/data]");
-        memo.append("[data]" + hop_forms[product->hops.at(i).form] + "[/data]");
+        memo.append("[data]" + QCoreApplication::translate("HopForm", g_hop_forms[product->hops.at(i).form]) + "[/data]");
         memo.append("[data]" + QString::number(product->hops.at(i).alpha, 'f', 1) + "[/data]");
         memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]");
         memo.append("[data]" + QString::number(product->hops.at(i).amount * 1000, 'f', 2) + "[/data]");
         if (product->hops.at(i).useat == HOP_USEAT_BOIL || product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL)
-            memo.append("[data]" + hop_use[product->hops.at(i).useat] + " " + QString::number(product->hops.at(i).time) + " minuten[/data][/row]\n");
+            memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[product->hops.at(i).useat]) + " " + QString::number(product->hops.at(i).time) + " minuten[/data][/row]\n");
         else if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP)
-            memo.append("[data]" + hop_use[product->hops.at(i).useat] + " " + QString::number(product->hops.at(i).time / 1440) + " dagen[/data][/row]\n");
+            memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[product->hops.at(i).useat]) + " " + QString::number(product->hops.at(i).time / 1440) + " dagen[/data][/row]\n");
         else
-            memo.append("[data]" + hop_use[product->hops.at(i).useat] + "[/data][/row]\n");
+            memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[product->hops.at(i).useat]) + "[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
 
@@ -493,11 +475,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 < product->miscs.size(); i++) {
         memo.append("[row][data]" + product->miscs.at(i).name + "[/data]");
-        memo.append("[data]" + misc_type[product->miscs.at(i).type] + "[/data]");
+        memo.append("[data]" + QCoreApplication::translate("MiscType", g_misc_types[product->miscs.at(i).type]) + "[/data]");
         if (product->miscs.at(i).use_use == MISC_USES_BOIL)
-            memo.append("[data]" + misc_use[product->miscs.at(i).use_use] + " " + QString::number(product->miscs.at(i).time) + " min[/data]");
+            memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(i).use_use]) + " " + QString::number(product->miscs.at(i).time) + " min[/data]");
         else
-            memo.append("[data]" + misc_use[product->miscs.at(i).use_use] + "[/data]");
+            memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(i).use_use]) + "[/data]");
         memo.append("[data]"+QString::number(product->miscs.at(i).amount * 1000, 'f', 2)+((product->miscs.at(i).amount_is_weight)?" gr":" ml")+"[/data][/row]\n");
     }
     memo.append("[/tabular]\n\n");
@@ -508,8 +490,8 @@
     for (int i = 0; i < product->yeasts.size(); i++) {
         memo.append("[row][data]" + product->yeasts.at(i).laboratory + " " + product->yeasts.at(i).product_id + "[/data]");
         memo.append("[data]" + product->yeasts.at(i).name + "[/data]");
-        memo.append("[data]" + yeast_use[product->yeasts.at(i).use] + "[/data]");
-        memo.append("[data]" + yeast_form[product->yeasts.at(i).form] + "[/data]");
+        memo.append("[data]" + QCoreApplication::translate("YeastUse", g_yeast_use[product->yeasts.at(i).use]) + "[/data]");
+        memo.append("[data]" + QCoreApplication::translate("YeastForm", g_yeast_forms[product->yeasts.at(i).form]) + "[/data]");
         if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
             memo.append("[data]" + QString::number(product->yeasts.at(i).amount, 'f', 0) + " pak[/data][/row]\n");
         else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
@@ -534,9 +516,9 @@
     for (int i = 0; i < product->mashs.size(); i++) {
         memo.append("[row][data]" + product->mashs.at(i).step_name + "[/data]");
         if (product->mashs.at(i).step_type != 1)
-            memo.append("[data]" + step_type[product->mashs.at(i).step_type]+" "+QString::number(product->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]");
+            memo.append("[data]" + QCoreApplication::translate("StepType", g_step_types[product->mashs.at(i).step_type])+" "+QString::number(product->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]");
         else
-            memo.append("[data]" + step_type[product->mashs.at(i).step_type] + "[/data]");
+            memo.append("[data]" + QCoreApplication::translate("StepType", g_step_types[product->mashs.at(i).step_type]) + "[/data]");
         memo.append("[data]" + QString::number(product->mashs.at(i).step_temp, 'f', 1) + " °C[/data]");
         memo.append("[data]" + QString::number(product->mashs.at(i).step_time, 'f', 0) + " min[/data]");
         memo.append("[data]" + QString::number(product->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n");

mercurial