src/EditProductExport.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 394
f41d02c129e5
child 402
3af1d728b02f
permissions
-rw-r--r--

Init est_carb field for new products.

175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProduct.cpp is part of bmsapp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Export product.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
237
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
21 void EditProduct::exportBeerXML()
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 qDebug() << "export";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
384
d68826df8b63 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
26 const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet", "Pellet" });
d68826df8b63 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
27 /* "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 /* We use more hop forms then beerxml knows about, so we send known names */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 /* instead of what we internally use. */
304
aa8d421bfc24 Added remarks about beerxml design flaws.
Michiel Broek <mbroek@mbse.eu>
parents: 302
diff changeset
30
aa8d421bfc24 Added remarks about beerxml design flaws.
Michiel Broek <mbroek@mbse.eu>
parents: 302
diff changeset
31 /* Note: Whirlpool hop is Aroma + time. Hop at flame-off is Aroma with time = 0. BeerXML is really stupid designed. */
aa8d421bfc24 Added remarks about beerxml design flaws.
Michiel Broek <mbroek@mbse.eu>
parents: 302
diff changeset
32 /* flame-off vv vv whirlpool hop */
aa8d421bfc24 Added remarks about beerxml design flaws.
Michiel Broek <mbroek@mbse.eu>
parents: 302
diff changeset
33 const QStringList hop_use({ "Mash", "First wort", "Boil", "Aroma", "Aroma", "Dry hop", "Dry hop" }); // tetra == dry-hop :(
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 const QStringList yeast_type({ "Lager", "Ale", "Wheat", "Wine", "Champagne", "Other", "Other", "Other", "Other", "Other" });
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 const QStringList yeast_form({ "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dry" });
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
37 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
38 QDir::homePath() + "/" + product->code + " " + product->name + ".xml", tr("Files (*.xml)"));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 if (fileName == 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 QMessageBox::warning(this, tr("Save File"), tr("No XML file selected."));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 QFile file(fileName);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 file.open(QIODevice::WriteOnly);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 xmlWriter->writeStartDocument();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 xmlWriter->setAutoFormatting(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 xmlWriter->setAutoFormattingIndent(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 xmlWriter->writeStartElement("RECIPES");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 xmlWriter->writeStartElement("RECIPE");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 * Product basics
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 xmlWriter->writeTextElement("NAME", product->name);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 if (product->notes != "")
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 xmlWriter->writeTextElement("NOTES", product->notes);
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
61 xmlWriter->writeTextElement("TYPE", g_recipe_types[product->type]);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 xmlWriter->writeTextElement("BREWER", "Anonymous");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 xmlWriter->writeTextElement("BATCH_SIZE", QString::number(product->batch_size, 'f', 4));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 xmlWriter->writeTextElement("BOIL_SIZE", QString::number(product->boil_size, 'f', 4));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 xmlWriter->writeTextElement("BOIL_TIME", QString::number(product->boil_time, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 xmlWriter->writeTextElement("EFFICIENCY", QString::number(product->efficiency, 'f', 4));
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
67 if (product->og > 0.9)
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
68 xmlWriter->writeTextElement("OG", QString::number(product->og, 'f', 3));
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
69 if (product->fg > 0.9)
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
70 xmlWriter->writeTextElement("FG", QString::number(product->fg, 'f', 3));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 xmlWriter->writeTextElement("EST_OG", QString::number(product->est_og, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 xmlWriter->writeTextElement("EST_FG", QString::number(product->est_fg, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 if (product->est_abv > 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 xmlWriter->writeTextElement("EST_ABV", QString::number(product->est_abv, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 if (product->est_color > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 xmlWriter->writeTextElement("EST_COLOR", QString::number(Utils::ebc_to_srm(product->est_color), 'f', 6));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 xmlWriter->writeTextElement("COLOR_METHOD", color_method[product->color_method]);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 if (product->est_ibu > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 xmlWriter->writeTextElement("EST_IBU", QString::number(product->est_ibu, 'f', 1));
339
2f3cfb983fcc Removed Garetz and Rager IBU calculations, we will only use Tinseth
Michiel Broek <mbroek@mbse.eu>
parents: 336
diff changeset
81 xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[0]); // Only Tinseth
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 }
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
83 xmlWriter->writeTextElement("BMS_COOLING_TO", QString::number(product->brew_cooling_to, 'f', 1));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 xmlWriter->writeStartElement("STYLE");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 xmlWriter->writeTextElement("NAME", product->st_name);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 xmlWriter->writeTextElement("CATEGORY", product->st_category);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 xmlWriter->writeTextElement("CATEGORY_NUMBER", QString::number(product->st_category_number, 'f', 0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 xmlWriter->writeTextElement("STYLE_LETTER", product->st_letter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 xmlWriter->writeTextElement("STYLE_GUIDE", product->st_guide);
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
92 xmlWriter->writeTextElement("TYPE", g_style_types[product->st_type]);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 xmlWriter->writeTextElement("OG_MIN", QString::number(product->st_og_min, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 xmlWriter->writeTextElement("OG_MAX", QString::number(product->st_og_max, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 xmlWriter->writeTextElement("FG_MIN", QString::number(product->st_fg_min, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 xmlWriter->writeTextElement("FG_MAX", QString::number(product->st_fg_max, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 xmlWriter->writeTextElement("IBU_MIN", QString::number(product->st_ibu_min, 'f', 0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 xmlWriter->writeTextElement("IBU_MAX", QString::number(product->st_ibu_max, 'f', 0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 xmlWriter->writeTextElement("COLOR_MIN", QString::number(Utils::ebc_to_srm(product->st_color_min), 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 xmlWriter->writeTextElement("COLOR_MAX", QString::number(Utils::ebc_to_srm(product->st_color_max), 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 xmlWriter->writeTextElement("CARB_MIN", QString::number(product->st_carb_min, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 xmlWriter->writeTextElement("CARB_MAX", QString::number(product->st_carb_max, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 xmlWriter->writeTextElement("ABV_MIN", QString::number(product->st_abv_min, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 xmlWriter->writeTextElement("ABV_MAX", QString::number(product->st_abv_max, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 xmlWriter->writeEndElement(); // STYLE
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 xmlWriter->writeStartElement("EQUIPMENT");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 xmlWriter->writeTextElement("VERSION", "1");
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
109 xmlWriter->writeTextElement("NAME", product->eq_name);
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
110 xmlWriter->writeTextElement("NOTES", product->eq_notes);
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
111 xmlWriter->writeTextElement("BATCH_SIZE", QString::number(product->eq_batch_size, 'f', 2));
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
112 xmlWriter->writeTextElement("BOIL_SIZE", QString::number(product->eq_boil_size, 'f', 2));
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
113 xmlWriter->writeTextElement("BOIL_TIME", QString::number(product->eq_boil_time, 'f', 0));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 xmlWriter->writeEndElement(); // EQUIPMENT
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 xmlWriter->writeStartElement("HOPS");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 for (int i = 0; i < product->hops.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 xmlWriter->writeStartElement("HOP");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 xmlWriter->writeTextElement("VERSION", "1");
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
120 xmlWriter->writeTextElement("NAME", product->hops.at(i).name);
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
121 xmlWriter->writeTextElement("ALPHA", QString::number(product->hops.at(i).alpha, 'f', 1));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
122 xmlWriter->writeTextElement("AMOUNT", QString::number(product->hops.at(i).amount, 'f', 4));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
123 xmlWriter->writeTextElement("USE", hop_use[product->hops.at(i).useat]);
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
124 xmlWriter->writeTextElement("TIME", QString::number(product->hops.at(i).time, 'f', 0));
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
125 xmlWriter->writeTextElement("TYPE", g_hop_types[product->hops.at(i).type]);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
126 xmlWriter->writeTextElement("FORM", hop_forms[product->hops.at(i).form]);
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
127 xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).beta, 'f', 1));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
128 xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).hsi, 'f', 1));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
129 xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).origin);
384
d68826df8b63 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
130 xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[product->hops.at(i).form]);
d68826df8b63 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
131 xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(product->hops.at(i).utilisation, 'f', 4));
d68826df8b63 Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
132 xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(product->hops.at(i).bu_factor, 'f', 1));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 xmlWriter->writeEndElement(); // HOPS
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 xmlWriter->writeStartElement("FERMENTABLES");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
139 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
140 xmlWriter->writeStartElement("FERMENTABLE");
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
141 xmlWriter->writeTextElement("VERSION", "1");
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
142 xmlWriter->writeTextElement("NAME", product->fermentables.at(i).name);
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
143 xmlWriter->writeTextElement("TYPE", g_fermentable_types[product->fermentables.at(i).type]);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
144 xmlWriter->writeTextElement("AMOUNT", QString::number(product->fermentables.at(i).amount, 'f', 4));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
145 xmlWriter->writeTextElement("YIELD", QString::number(product->fermentables.at(i).yield, 'f', 1));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
146 xmlWriter->writeTextElement("COLOR", QString::number(Utils::ebc_to_srm(product->fermentables.at(i).color), 'f', 1));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
147 xmlWriter->writeTextElement("ADD_AFTER_BOIL", product->fermentables.at(i).add_after_boil ? "TRUE":"FALSE");
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
148 xmlWriter->writeTextElement("ORIGIN", product->fermentables.at(i).origin);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
149 xmlWriter->writeTextElement("SUPPLIER", product->fermentables.at(i).supplier);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
150 if (product->fermentables.at(i).coarse_fine_diff)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
151 xmlWriter->writeTextElement("COARSE_FINE_DIFF", QString::number(product->fermentables.at(i).coarse_fine_diff, 'f', 4));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
152 if (product->fermentables.at(i).moisture)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
153 xmlWriter->writeTextElement("MOISTURE", QString::number(product->fermentables.at(i).moisture, 'f', 4));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
154 if (product->fermentables.at(i).diastatic_power)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
155 xmlWriter->writeTextElement("DIASTATIC_POWER", QString::number(product->fermentables.at(i).diastatic_power, 'f', 4));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
156 if (product->fermentables.at(i).protein)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
157 xmlWriter->writeTextElement("PROTEIN", QString::number(product->fermentables.at(i).protein, 'f', 4));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
158 if (product->fermentables.at(i).max_in_batch)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
159 xmlWriter->writeTextElement("MAX_IN_BATCH", QString::number(product->fermentables.at(i).max_in_batch, 'f', 1));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
160 xmlWriter->writeTextElement("RECOMMEND_MASH", product->fermentables.at(i).recommend_mash ? "TRUE":"FALSE");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
161 xmlWriter->writeTextElement("GRAINTYPE", g_fermentable_graintypes[product->fermentables.at(i).graintype]);
246
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
162 xmlWriter->writeEndElement();
9e420bea7c38 Product beerXML updates: Add product code to beerxml filename. Add OG and FG values if valid. Fixed equipment values to use the real equipment profile. Don't export fermentables that are used for packaging.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
163 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 xmlWriter->writeEndElement(); // FERMENTABLES
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 xmlWriter->writeStartElement("MISCS");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 for (int i = 0; i < product->miscs.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 xmlWriter->writeStartElement("MISC");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 xmlWriter->writeTextElement("VERSION", "1");
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
171 xmlWriter->writeTextElement("NAME", product->miscs.at(i).name);
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
172 xmlWriter->writeTextElement("TYPE", g_misc_types[product->miscs.at(i).type]);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
173 xmlWriter->writeTextElement("AMOUNT", QString::number(product->miscs.at(i).amount, 'f', 5));
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
174 xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", product->miscs.at(i).amount_is_weight ? "TRUE":"FALSE");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
175 xmlWriter->writeTextElement("USE", g_misc_uses[product->miscs.at(i).use_use]);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
176 xmlWriter->writeTextElement("TIME", QString::number(product->miscs.at(i).time, 'f', 0));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 xmlWriter->writeEndElement(); // MISCS
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 xmlWriter->writeStartElement("YEASTS");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 for (int i = 0; i < product->yeasts.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 xmlWriter->writeStartElement("YEAST");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 xmlWriter->writeTextElement("VERSION", "1");
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
185 xmlWriter->writeTextElement("NAME", product->yeasts.at(i).name);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
186 xmlWriter->writeTextElement("TYPE", yeast_type[product->yeasts.at(i).type]);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
187 xmlWriter->writeTextElement("FORM", yeast_form[product->yeasts.at(i).form]);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
188 xmlWriter->writeTextElement("AMOUNT", QString::number(product->yeasts.at(i).amount, 'f', 5));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
189 xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", (product->yeasts.at(i).form == 1) ? "TRUE":"FALSE");
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
190 xmlWriter->writeTextElement("LABORATORY", product->yeasts.at(i).laboratory);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
191 xmlWriter->writeTextElement("PRODUCT_ID", product->yeasts.at(i).product_id);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
192 xmlWriter->writeTextElement("MIN_TEMPERATURE", QString::number(product->yeasts.at(i).min_temperature, 'f', 1));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
193 xmlWriter->writeTextElement("MAX_TEMPERATURE", QString::number(product->yeasts.at(i).max_temperature, 'f', 1));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
194 xmlWriter->writeTextElement("ATTENUATION", QString::number(product->yeasts.at(i).attenuation, 'f', 1));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
195 xmlWriter->writeTextElement("ADD_TO_SECONDARY", (product->yeasts.at(i).use == 0) ? "FALSE":"TRUE");
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 xmlWriter->writeEndElement(); // YEASTS
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 xmlWriter->writeStartElement("WATERS");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 if (product->w1_amount > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 xmlWriter->writeStartElement("WATER");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 xmlWriter->writeTextElement("NAME", product->w1_name);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 xmlWriter->writeTextElement("AMOUNT", QString::number(product->w1_amount, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 xmlWriter->writeTextElement("CALCIUM", QString::number(product->w1_calcium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 xmlWriter->writeTextElement("MAGNESIUM", QString::number(product->w1_magnesium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 xmlWriter->writeTextElement("BICARBONATE", QString::number(product->w1_total_alkalinity * 1.22, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 xmlWriter->writeTextElement("SULFATE", QString::number(product->w1_sulfate, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 xmlWriter->writeTextElement("CHLORIDE", QString::number(product->w1_chloride, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 xmlWriter->writeTextElement("SODIUM", QString::number(product->w1_sodium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 xmlWriter->writeTextElement("PH", QString::number(product->w1_ph, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 xmlWriter->writeTextElement("TOTAL_ALKALINITY", QString::number(product->w1_total_alkalinity, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 if (product->w2_amount > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 xmlWriter->writeStartElement("WATER");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 xmlWriter->writeTextElement("NAME", product->w2_name);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 xmlWriter->writeTextElement("AMOUNT", QString::number(product->w2_amount, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 xmlWriter->writeTextElement("CALCIUM", QString::number(product->w2_calcium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 xmlWriter->writeTextElement("MAGNESIUM", QString::number(product->w2_magnesium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 xmlWriter->writeTextElement("BICARBONATE", QString::number(product->w2_total_alkalinity * 1.22, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 xmlWriter->writeTextElement("SULFATE", QString::number(product->w2_sulfate, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 xmlWriter->writeTextElement("CHLORIDE", QString::number(product->w2_chloride, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 xmlWriter->writeTextElement("SODIUM", QString::number(product->w2_sodium, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 xmlWriter->writeTextElement("PH", QString::number(product->w2_ph, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 xmlWriter->writeTextElement("TOTAL_ALKALINITY", QString::number(product->w2_total_alkalinity, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 xmlWriter->writeEndElement(); // WATERS
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 xmlWriter->writeStartElement("MASH");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 xmlWriter->writeTextElement("NAME", product->mash_name);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 xmlWriter->writeTextElement("GRAIN_TEMP", "10.0");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 xmlWriter->writeTextElement("PH", QString::number(product->sparge_ph, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 xmlWriter->writeTextElement("SPARGE_TEMP", QString::number(product->sparge_temp, 'f', 2));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 xmlWriter->writeStartElement("MASH_STEPS");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 for (int i = 0; i < product->mashs.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 xmlWriter->writeStartElement("MASH_STEP");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 xmlWriter->writeTextElement("VERSION", "1");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 xmlWriter->writeTextElement("NAME", product->mashs.at(i).step_name);
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
244 xmlWriter->writeTextElement("TYPE", g_step_types[product->mashs.at(i).step_type]);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 if (product->mashs.at(i).step_type == 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 xmlWriter->writeTextElement("INFUSE_AMOUNT", QString::number(product->mashs.at(i).step_infuse_amount, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 xmlWriter->writeTextElement("INFUSE_TEMP", QString::number(product->mashs.at(i).step_infuse_temp, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 if (product->mashs.at(i).step_type == 2) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 xmlWriter->writeTextElement("DECOCTION_AMT", QString::number(product->mashs.at(i).step_infuse_amount, 'f', 3));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 xmlWriter->writeTextElement("STEP_TEMP", QString::number(product->mashs.at(i).step_temp, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 xmlWriter->writeTextElement("STEP_TIME", QString::number(product->mashs.at(i).step_time, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 xmlWriter->writeTextElement("RAMP_TIME", QString::number(product->mashs.at(i).ramp_time, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 xmlWriter->writeTextElement("END_TEMP", QString::number(product->mashs.at(i).end_temp, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 xmlWriter->writeTextElement("PH", QString::number(product->mash_ph, 'f', 1));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 xmlWriter->writeEndElement();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 xmlWriter->writeEndElement(); // MASH_STEPS
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 xmlWriter->writeEndElement(); // MASH
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 xmlWriter->writeEndElement(); // RECIPE
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 xmlWriter->writeEndElement(); // RECIPES
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 xmlWriter->writeEndDocument();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 QMessageBox::information(this, tr("Save File"), tr("XML export ready"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 file.close();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
270 void EditProduct::copyProduct()
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
271 {
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
272 Product *dup = new Product;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
273
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
274 dup = product;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
275 dup->record = -1;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
276 dup->uuid = "";
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
277 dup->name.append(" [duplicate]");
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
278 dup->code.append("-[dup]");
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
279 /*
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
280 * Clear data of a previous brew if present and roll back stages.
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
281 * But leave all ingredients and volumes, that's what we want.
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
282 */
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
283 if (dup->stage > PROD_STAGE_WAIT) {
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
284 dup->stage = dup->inventory_reduced = PROD_STAGE_WAIT;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
285 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
286 dup->birth = QDate::currentDate();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
287 dup->brew_date_start = dup->brew_date_end = QDateTime();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
288 dup->brew_mash_ph = dup->brew_mash_sg = dup->brew_mash_efficiency = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
289 dup->brew_sparge_ph = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
290 dup->brew_preboil_volume = dup->brew_preboil_sg = dup->brew_preboil_ph = dup->brew_preboil_efficiency = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
291 dup->brew_aboil_volume = dup->brew_aboil_sg = dup->brew_aboil_ph = dup->brew_aboil_efficiency = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
292 dup->brew_cooling_time = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
293 dup->brew_fermenter_volume = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
294 dup->brew_fermenter_sg = dup->brew_fermenter_ibu = dup->brew_fermenter_color = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
295 dup->og = dup->fg = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
296 dup->primary_start_temp = dup->primary_max_temp = dup->primary_end_temp = dup->primary_end_sg = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
297 dup->primary_end_date = dup->secondary_end_date = QDate();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
298 dup->secondary_temp = dup->secondary_end_sg = dup->tertiary_temp = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
299 dup->package_date = QDate();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
300 dup->package_volume = dup->package_abv = dup->package_ph = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
301 dup->bottle_amount = dup->bottle_carbonation = dup->bottle_priming_amount = dup->bottle_carbonation_temp = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
302 dup->keg_amount = dup->keg_carbonation = dup->keg_priming_amount = dup->keg_carbonation_temp = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
303 dup->bottle_priming_water = dup->keg_priming_water = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
304 dup->taste_rate = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
305 dup->taste_date = QDate();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
306 dup->taste_notes = dup->taste_color = dup->taste_transparency = dup->taste_head = "";
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
307 dup->taste_aroma = dup->taste_taste = dup->taste_mouthfeel = dup->taste_aftertaste = "";
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
308 dup->starter_viability = 100;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
309 dup->yeast_prod_date = QDate();
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
310 dup->divide_type = dup->divide_parts = dup->divide_part = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
311 dup->divide_size = 0;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
312 dup->divide_factor = 1;
394
f41d02c129e5 Clear log flags and starter volumes when a product is duplicated.
Michiel Broek <mbroek@mbse.eu>
parents: 384
diff changeset
313 dup->log_brew = dup->log_fermentation = dup->log_ispindel = dup->log_co2pressure = dup->locked = 0;
f41d02c129e5 Clear log flags and starter volumes when a product is duplicated.
Michiel Broek <mbroek@mbse.eu>
parents: 384
diff changeset
314 dup->prop_volume[0] = dup->prop_volume[1] = dup->prop_volume[2] = dup->prop_volume[3] = 0;
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
315
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
316 qDebug() << dup->record << dup->name;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
317 if (DB_product::save(dup, this)) {
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
318 QMessageBox::information(this, tr("Copy Product"), tr("Copy Product export ready."));
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
319 } else {
273
eb9b50a4bf35 Version 0.2.9. Fixed a few spelling errors. Updated Dutch translations.
Michiel Broek <mbroek@mbse.eu>
parents: 271
diff changeset
320 QMessageBox::warning(this, tr("Copy Product"), tr("Copy Product error."));
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
321 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
322 delete dup;
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
323 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
324
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
325
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
326 void EditProduct::copyRecipe()
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
327 {
265
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
328 Recipe *r = new Recipe;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
329
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
330 r->record = -1;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
331 r->name = product->name + QString(" [duplicate]");
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
332 r->notes = product->notes;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
333 r->locked = false;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
334 r->st_name = product->st_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
335 r->st_letter = product->st_letter;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
336 r->st_guide = product->st_guide;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
337 r->st_category = product->st_category;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
338 r->st_category_number = product->st_category_number;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
339 r->st_og_min = product->st_og_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
340 r->st_og_max = product->st_og_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
341 r->st_fg_min = product->st_fg_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
342 r->st_fg_max = product->st_fg_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
343 r->st_ibu_min = product->st_ibu_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
344 r->st_ibu_max = product->st_ibu_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
345 r->st_color_min = product->st_color_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
346 r->st_color_max = product->st_color_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
347 r->st_carb_min = product->st_carb_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
348 r->st_carb_max = product->st_carb_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
349 r->st_abv_min = product->st_abv_min;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
350 r->st_abv_max = product->st_abv_max;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
351 r->type = product->type;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
352 r->batch_size = product->batch_size;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
353 r->boil_size = product->boil_size;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
354 r->boil_time = product->boil_time;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
355 r->efficiency = product->efficiency;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
356 r->est_og = product->est_og;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
357 r->est_fg = product->est_fg;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
358 r->est_abv = product->est_abv;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
359 r->est_carb = 0;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
360 r->est_color = product->est_color;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
361 r->color_method = product->color_method;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
362 r->est_ibu = product->est_ibu;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
363 r->ibu_method = product->ibu_method;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
364 r->sparge_temp = product->sparge_temp;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
365 r->sparge_volume = product->sparge_volume;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
366 r->sparge_ph = product->sparge_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
367 r->sparge_acid_type = product->sparge_acid_type;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
368 r->sparge_acid_perc = product->sparge_acid_perc;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
369 r->sparge_acid_amount = 0;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
370 r->mash_ph = product->mash_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
371 r->mash_name = product->mash_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
372 r->calc_acid = product->calc_acid;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
373 r->w1_name = product->w1_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
374 r->w1_amount = product->w1_amount;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
375 r->w1_calcium = product->w1_calcium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
376 r->w1_sulfate = product->w1_sulfate;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
377 r->w1_chloride = product->w1_chloride;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
378 r->w1_sodium = product->w1_sodium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
379 r->w1_magnesium = product->w1_magnesium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
380 r->w1_total_alkalinity = product->w1_total_alkalinity;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
381 r->w1_ph = product->w1_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
382 r->w2_name = product->w2_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
383 r->w2_amount = product->w2_amount;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
384 r->w2_calcium = product->w2_calcium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
385 r->w2_sulfate = product->w2_sulfate;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
386 r->w2_chloride = product->w2_chloride;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
387 r->w2_sodium = product->w2_sodium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
388 r->w2_magnesium = product->w2_magnesium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
389 r->w2_total_alkalinity = product->w2_total_alkalinity;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
390 r->w2_ph = product->w2_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
391 r->wg_amount = product->wg_amount;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
392 r->wg_calcium = product->wg_calcium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
393 r->wg_sulfate = product->wg_sulfate;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
394 r->wg_chloride = product->wg_chloride;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
395 r->wg_sodium = product->wg_sodium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
396 r->wg_magnesium = product->wg_magnesium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
397 r->wg_total_alkalinity = product->wg_total_alkalinity;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
398 r->wg_ph = product->wg_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
399 r->wb_calcium = product->wb_calcium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
400 r->wb_sulfate = product->wb_sulfate;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
401 r->wb_chloride = product->wb_chloride;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
402 r->wb_sodium = product->wb_sodium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
403 r->wb_magnesium = product->wb_magnesium;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
404 r->wb_total_alkalinity = product->wb_total_alkalinity;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
405 r->wb_ph = product->wb_ph;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
406 r->wa_acid_name = product->wa_acid_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
407 r->wa_acid_perc = product->wa_acid_perc;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
408 r->wa_base_name = product->wa_base_name;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
409 r->fermentables = product->fermentables;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
410 r->hops = product->hops;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
411 r->miscs = product->miscs;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
412 r->yeasts = product->yeasts;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
413 r->mashs = product->mashs;
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
414
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
415 if (DB_recipe::save(r, this)) {
273
eb9b50a4bf35 Version 0.2.9. Fixed a few spelling errors. Updated Dutch translations.
Michiel Broek <mbroek@mbse.eu>
parents: 271
diff changeset
416 QMessageBox::information(this, tr("Copy Product"), tr("Copy Product to Recipe ready."));
265
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
417 } else {
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
418 QMessageBox::warning(this, tr("Copy Product"), tr("Copy Product to Recipe error."));
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
419 }
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
420 delete r;
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
421 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
422
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
423
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
424 void EditProduct::toforumProduct()
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
425 {
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
426 const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
427
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
428 QString memo = QString("[u][b]BMSapp v");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
429 memo.append(VERSIONSTRING); // For some stupid reason this must be on it's own.
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
430 memo.append(" - Datum export: " + QDate::currentDate().toString("dd-MMM-yyyy") + "[/b][/u]\n\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
431 memo.append("[u][b]Basis[/b][/u]\n[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
432 memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
433 memo.append("[row][data]Bier naam[/data][data]" + product->name + "[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
434 memo.append("[row][data]Bier stijl[/data][data]" + product->st_name + "[/data][/row]\n");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
435 memo.append("[row][data]Recept type[/data][data]" + QCoreApplication::translate("RecipeType", g_recipe_types[product->type]) + "[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
436 memo.append("[row][data]Batch grootte[/data][data]" + QString::number(product->batch_size, 'f', 1) + " L[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
437 memo.append("[row][data]Kooktijd[/data][data]" + QString::number(product->boil_time, 'f', 0) + " minuten[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
438 memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(product->efficiency, 'f', 1) + "%[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
439 memo.append("[row][data]Geschatte begin densiteit[/data][data]" + QString::number(product->est_og, 'f', 3) + " SG[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
440 memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(product->est_fg, 'f', 3) + " SG[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
441 memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(product->est_abv, 'f', 1) + "%[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
442 memo.append("[row][data]Kleur (" + color_method[product->color_method] + ")[/data][data]" + QString::number(product->est_color, 'f', 0) + " EBC[/data][/row]\n");
336
e97f9e87d94b IBU method names are now global.
Michiel Broek <mbroek@mbse.eu>
parents: 304
diff changeset
443 memo.append("[row][data]Bitterheid (" + QString(g_ibu_method[product->ibu_method]) + ")[/data][data]" + QString::number(product->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
444 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
445
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
446 memo.append("[u][b]Vergistbare ingrediënten[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
447 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
448 memo.append("[head]Mout, granen en suikers[/head][head]EBC[/head][head]Gewicht kg[/head][head]%[/head][head]Gebruik tijdens[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
449 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
450 memo.append("[row][data]" + product->fermentables.at(i).name + " (" + product->fermentables.at(i).supplier + ")[/data]");
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
451 memo.append("[data]" + QString::number(product->fermentables.at(i).color) + "[/data]");
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
452 memo.append("[data]" + QString::number(product->fermentables.at(i).amount, 'f', 3) + "[/data]");
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
453 memo.append("[data]" + QString::number(product->fermentables.at(i).percentage, 'f', 1) + "[/data]");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
454 memo.append("[data]" + QCoreApplication::translate("FermentableAdded", g_fermentable_added[product->fermentables.at(i).added]) + "[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
455 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
456 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
457
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
458 memo.append("[u][b]Hop[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
459 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
460 memo.append("[head]Hop[/head][head]Vorm[/head][head]Alpha[/head][head]IBU[/head][head]Gram[/head][head]Toevoegen moment[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
461 for (int i = 0; i < product->hops.size(); i++) {
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
462 double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->est_og3, product->batch_size,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
463 product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 339
diff changeset
464 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
465 product->brew_cooling_method, 0, 0, product->hops.at(i).utilisation, product->hops.at(i).bu_factor);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
466 memo.append("[row][data]" + product->hops.at(i).name + " (" + product->hops.at(i).origin + ")[/data]");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
467 memo.append("[data]" + QCoreApplication::translate("HopForm", g_hop_forms[product->hops.at(i).form]) + "[/data]");
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
468 memo.append("[data]" + QString::number(product->hops.at(i).alpha, 'f', 1) + "[/data]");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
469 memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]");
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
470 memo.append("[data]" + QString::number(product->hops.at(i).amount * 1000, 'f', 2) + "[/data]");
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
471 if (product->hops.at(i).useat == HOP_USEAT_BOIL || product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL)
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
472 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");
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
473 else if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP)
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
474 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");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
475 else
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
476 memo.append("[data]" + QCoreApplication::translate("HopUse", g_hop_useat[product->hops.at(i).useat]) + "[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
477 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
478 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
479
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
480 memo.append("[u][b]Diversen[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
481 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
482 memo.append("[head]Specerij, kruid, brouwzout[/head][head]Type grondstof[/head][head]Gebruik tijdens[/head][head]Hoeveel[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
483 for (int i = 0; i < product->miscs.size(); i++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
484 memo.append("[row][data]" + product->miscs.at(i).name + "[/data]");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
485 memo.append("[data]" + QCoreApplication::translate("MiscType", g_misc_types[product->miscs.at(i).type]) + "[/data]");
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
486 if (product->miscs.at(i).use_use == MISC_USES_BOIL)
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
487 memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(i).use_use]) + " " + QString::number(product->miscs.at(i).time) + " min[/data]");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
488 else
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
489 memo.append("[data]" + QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(i).use_use]) + "[/data]");
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
490 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");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
491 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
492 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
493
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
494 memo.append("[u][b]Gist[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
495 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
496 memo.append("[head]Gistlab en code[/head][head]Omschrijving[/head][head]Gebruik[/head][head]Vorm[/head][head]Hoeveel[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
497 for (int i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
498 memo.append("[row][data]" + product->yeasts.at(i).laboratory + " " + product->yeasts.at(i).product_id + "[/data]");
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
499 memo.append("[data]" + product->yeasts.at(i).name + "[/data]");
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
500 memo.append("[data]" + QCoreApplication::translate("YeastUse", g_yeast_use[product->yeasts.at(i).use]) + "[/data]");
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
501 memo.append("[data]" + QCoreApplication::translate("YeastForm", g_yeast_forms[product->yeasts.at(i).form]) + "[/data]");
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
502 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
503 memo.append("[data]" + QString::number(product->yeasts.at(i).amount, 'f', 0) + " pak[/data][/row]\n");
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
504 else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
505 memo.append("[data]" + QString::number(product->yeasts.at(i).amount * 1000, 'f', 1) + " gr[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
506 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
507 memo.append("[data]" + QString::number(product->yeasts.at(i).amount * 1000, 'f', 0) + " ml[/data][/row]\n");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
508 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
509 memo.append("[/tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
510 if (product->starter_enable) {
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
511 double sv = 0;
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
512 for (int i = 0; i < 4; i++) {
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
513 if ((product->prop_volume[i] > 0) && (product->prop_volume[i] > sv))
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
514 sv = product->prop_volume[i];
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
515 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
516 memo.append("Maak een giststarter van " + QString::number(sv, 'f', 1) + " liter.\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
517 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
518 memo.append("\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
519
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
520 memo.append("[u][b]Maischen[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
521 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
522 memo.append("[head]Maisch stap[/head][head]Stap type[/head][head]Temperatuur[/head][head]Rust tijd[/head][head]Opwarm tijd[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
523 for (int i = 0; i < product->mashs.size(); i++) {
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
524 memo.append("[row][data]" + product->mashs.at(i).step_name + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
525 if (product->mashs.at(i).step_type != 1)
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
526 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]");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
527 else
302
2e8462219332 Export recipe or product to beerxml use the global untranslated arrays. Export recipe or product to forum use the global translated arrays.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
528 memo.append("[data]" + QCoreApplication::translate("StepType", g_step_types[product->mashs.at(i).step_type]) + "[/data]");
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
529 memo.append("[data]" + QString::number(product->mashs.at(i).step_temp, 'f', 1) + " °C[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
530 memo.append("[data]" + QString::number(product->mashs.at(i).step_time, 'f', 0) + " min[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
531 memo.append("[data]" + QString::number(product->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
532 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
533 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
534
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
535 memo.append("[u][b]Brouwwater[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
536 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
537 memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
538 if (product->w2_name != "" && product->w2_amount > 0) {
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
539 memo.append("[row][data]Maischwater 1[/data][data]" + product->w1_name + " " + QString::number(product->w1_amount, 'f', 1) + " Liter[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
540 memo.append("[row][data]Maischwater 2[/data][data]" + product->w2_name + " " + QString::number(product->w2_amount, 'f', 1) + " Liter[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
541 } else {
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
542 memo.append("[row][data]Maischwater[/data][data]" + product->w1_name + " " + QString::number(product->w1_amount, 'f', 1) + " Liter[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
543 }
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
544 memo.append("[row][data]Maischwater aanzuren tot[/data][data]" + QString::number(product->mash_ph, 'f', 1) + " pH[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
545 memo.append("[row][data]Spoelwater geschat[/data][data]" + QString::number(product->brew_sparge_est, 'f', 1) + " Liter[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
546 memo.append("[row][data]Spoelwater temperatuur[/data][data]" + QString::number(product->sparge_temp, 'f', 1) + " °C[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
547 memo.append("[row][data]Spoelwater aanzuren tot[/data][data]" + QString::number(product->sparge_ph, 'f', 1) + " pH[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
548 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
549
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
550 memo.append("[u][b]Waterprofiel behandeld water[/b][/u]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
551 memo.append("[tabular]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
552 memo.append("[head]Ca[/head][head]Mg[/head][head]Na[/head][head]HCO3[/head][head]Cl[/head][head]SO4[/head]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
553 memo.append("[row][data]" + QString::number(product->wb_calcium, 'f', 1) + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
554 memo.append("[data]" + QString::number(product->wb_magnesium, 'f', 1) + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
555 memo.append("[data]" + QString::number(product->wb_sodium, 'f', 1) + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
556 memo.append("[data]" + QString::number(product->wb_total_alkalinity * 61 / 50, 'f', 1) + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
557 memo.append("[data]" + QString::number(product->wb_chloride, 'f', 1) + "[/data]");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
558 memo.append("[data]" + QString::number(product->wb_sulfate, 'f', 1) + "[/data][/row]\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
559 memo.append("[/tabular]\n\n");
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
560
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
561 qDebug().noquote() << memo;
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
562 QGuiApplication::clipboard()->setText(memo, QClipboard::Clipboard);
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
563 QGuiApplication::clipboard()->setText(memo, QClipboard::Selection);
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
564
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
565 QMessageBox::information(this, tr("Export to forum"), tr("The recipe and all data are copied to the clipboard.\n"
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
566 "You can \"paste\" this data in the forum screen in your web browser."));
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
567 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
568
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
569
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
570 void EditProduct::split_show()
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
571 {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
572 double left = vol_availEdit->value();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
573
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
574 qDebug() << "split_show" << product->splits.size();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
575 const QSignalBlocker blocker1(splitTable);
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
576
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
577 if (product->divide_type == 0) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
578 split_addButton->setEnabled(false);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
579 split_addButton->setToolTip("");
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
580 } else {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
581 split_addButton->setEnabled(true);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
582 split_addButton->setToolTip(tr("Add a splitted batch"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
583 }
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
584
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
585 if (product->splits.size() == 0) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
586 splitatEdit->setEnabled(true);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
587 splitatEdit->setToolTip(tr("Choose split moment in the brew process"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
588 split_delButton->setEnabled(false);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
589 split_delButton->setToolTip(tr(""));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
590 } else {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
591 splitatEdit->setEnabled(false);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
592 splitatEdit->setToolTip("");
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
593 split_delButton->setEnabled(true);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
594 split_delButton->setToolTip(tr("Delete the last splitted batch"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
595 }
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
596
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
597 for (int i = 0; i < product->splits.size(); i++) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
598
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
599 qDebug() << i << product->splits.at(i).code << product->splits.at(i).name << QString::number(product->splits.at(i).size);
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
600
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
601 QTableWidgetItem *item = new QTableWidgetItem(product->splits.at(i).code);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
602 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
603 item->setToolTip(tr("The read-only `product code` of the batch"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
604 splitTable->setItem(i, 0, item);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
605
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
606 item = new QTableWidgetItem(product->splits.at(i).name);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
607 item->setToolTip(tr("Batch name, click to change the name"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
608 splitTable->setItem(i, 1, item);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
609
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
610 item = new QTableWidgetItem(QString::number(product->splits.at(i).size, 'f', 2));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
611 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
612 item->setToolTip(tr("Batch size, click to change the volume"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
613 splitTable->setItem(i, 2, item);
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
614 left -= product->splits.at(i).size;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
615 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
616
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
617 if (left < 0)
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
618 left = 0;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
619 vol_leftEdit->setValue(left);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
620 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
621
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
622
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
623 void EditProduct::split_add_clicked()
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
624 {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
625 Splits news;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
626 int entry = product->splits.size();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
627
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
628 qDebug() << "split_add_clicked" << entry;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
629
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
630 news.name = product->name + QString(" %1").arg(entry + 1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
631 news.code = product->code + QString("-%1").arg(entry + 1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
632 news.size = 0;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
633 product->splits.append(news);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
634 splitTable->setRowCount(entry + 1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
635 split_show();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
636 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
637
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
638
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
639 void EditProduct::split_del_clicked()
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
640 {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
641 int last = product->splits.size() - 1;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
642
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
643 qDebug() << "split_del_clicked" << last;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
644
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
645 product->splits.removeAt(last);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
646 splitTable->setRowCount(last);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
647 split_show();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
648 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
649
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
650
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
651 void EditProduct::split_splitat_changed(int val)
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
652 {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
653 qDebug() << "split_splitat_changed" << val;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
654
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
655 switch (val) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
656 case 0: vol_availEdit->setValue(0);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
657 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
658 case 1: vol_availEdit->setValue(product->boil_size);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
659 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
660 case 2: vol_availEdit->setValue(product->batch_size);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
661 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
662 case 3: vol_availEdit->setValue(product->brew_fermenter_volume);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
663 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
664 case 4:
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
665 case 5: vol_availEdit->setValue(round(product->brew_fermenter_volume * 9.2) / 10.0); // Estimate without trub
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
666 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
667 case 6: vol_availEdit->setValue(product->package_volume);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
668 break;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
669 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
670 product->divide_type = val;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
671 split_show();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
672 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
673
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
674
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
675 void EditProduct::split_table_changed(int nRow, int nCol)
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
676 {
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
677 QTableWidgetItem *item;
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
678
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
679 qDebug() << "split_table_changed" << nRow << nCol;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
680
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
681 if (nCol == 1) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
682 /* Split name is changed. */
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
683 item = splitTable->item(nRow, nCol);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
684 product->splits[nRow].name = item->text();
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
685 }
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
686 if (nCol == 2) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
687 item = splitTable->item(nRow, nCol);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
688 double vol = item->text().toDouble();
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
689 double room = vol_availEdit->value();
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
690
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
691 for (int i = 0; i < product->splits.size(); i++) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
692 if (i != nRow)
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
693 room -= product->splits.at(i).size;
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
694 }
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
695 qDebug() << vol << room;
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
696 if (vol > (room - 1)) {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
697 product->splits[nRow].size = room - 1;
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
698 } else {
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
699 product->splits[nRow].size = round(vol * 100.0) / 100.0;
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
700 }
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
701 }
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
702
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
703 split_show();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
704 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
705
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
706
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
707 void EditProduct::splitProduct()
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
708 {
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
709 bool doit = false;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
710
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
711 if (this->textIsChanged) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
712 DB_product::save(product, this);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
713 this->textIsChanged = false;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
714 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
715
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
716 QDialog* dialog = new QDialog(this);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
717 dialog->setWindowTitle(tr("Split product"));
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
718 dialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
719 dialog->setObjectName(QString::fromUtf8("SplitDialog"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
720 dialog->resize(1024, 560);
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
721
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
722 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
723 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
724 buttonBox->setGeometry(QRect(30, 510, 961, 32));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
725 buttonBox->setOrientation(Qt::Horizontal);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
726 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
727 buttonBox->setCenterButtons(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
728 QLabel *topLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
729 topLabel->setObjectName(QString::fromUtf8("topLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
730 topLabel->setGeometry(QRect(30, 20, 961, 31));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
731 topLabel->setText(tr("Split product"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
732 QFont font;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
733 font.setPointSize(12);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
734 font.setBold(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
735 font.setWeight(75);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
736 topLabel->setFont(font);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
737 topLabel->setAlignment(Qt::AlignCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
738
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
739 QLabel *nameLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
740 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
741 nameLabel->setGeometry(QRect(20, 80, 141, 20));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
742 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
743 nameLabel->setText(tr("Product name:"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
744 QLineEdit *nameEdit = new QLineEdit(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
745 nameEdit->setObjectName(QString::fromUtf8("nameEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
746 nameEdit->setGeometry(QRect(170, 80, 481, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
747 nameEdit->setReadOnly(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
748 nameEdit->setText(product->name);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
749
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
750 QLabel *codeLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
751 codeLabel->setObjectName(QString::fromUtf8("codeLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
752 codeLabel->setGeometry(QRect(20, 110, 141, 20));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
753 codeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
754 codeLabel->setText(tr("Product code:"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
755 QLineEdit *codeEdit = new QLineEdit(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
756 codeEdit->setObjectName(QString::fromUtf8("codeEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
757 codeEdit->setGeometry(QRect(170, 110, 113, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
758 codeEdit->setReadOnly(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
759 codeEdit->setText(product->code);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
760
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
761 QLabel *vol_availLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
762 vol_availLabel->setObjectName(QString::fromUtf8("vol_availLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
763 vol_availLabel->setGeometry(QRect(20, 140, 141, 20));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
764 vol_availLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
765 vol_availLabel->setText(tr("Available volume:"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
766
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
767 QLabel *stageLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
768 stageLabel->setObjectName(QString::fromUtf8("stageLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
769 stageLabel->setGeometry(QRect(660, 80, 141, 20));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
770 stageLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
771 stageLabel->setText(tr("Current brew stage:"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
772 QLineEdit *stageEdit = new QLineEdit(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
773 stageEdit->setObjectName(QString::fromUtf8("stageEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
774 stageEdit->setGeometry(QRect(810, 80, 113, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
775 stageEdit->setReadOnly(true);
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
776 stageEdit->setText(QCoreApplication::translate("ProdStages", g_prod_stages[product->stage]));
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
777
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
778 QLabel *splitatLabel = new QLabel(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
779 splitatLabel->setObjectName(QString::fromUtf8("splitatLabel"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
780 splitatLabel->setGeometry(QRect(660, 110, 141, 20));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
781 splitatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
782 splitatLabel->setText(tr("Split at moment:"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
783 splitatEdit = new QComboBox(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
784 splitatEdit->setObjectName(QString::fromUtf8("splitatEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
785 splitatEdit->setGeometry(QRect(810, 110, 181, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
786 splitatEdit->addItem(tr("Not divided"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
787 splitatEdit->addItem(tr("After mash"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
788 splitatEdit->addItem(tr("After boil"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
789 splitatEdit->addItem(tr("After cooling"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
790 splitatEdit->addItem(tr("After primary"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
791 splitatEdit->addItem(tr("After secondary"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
792 splitatEdit->addItem(tr("After tertiary"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
793 /* Disable items that have been done. */
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
794 if (product->stage > PROD_STAGE_BREW) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
795 splitatEdit->setItemData(1, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
796 splitatEdit->setItemData(2, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
797 splitatEdit->setItemData(3, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
798 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
799 if (product->stage > PROD_STAGE_PRIMARY) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
800 splitatEdit->setItemData(4, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
801 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
802 if (product->stage > PROD_STAGE_SECONDARY) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
803 splitatEdit->setItemData(5, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
804 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
805 if (product->stage > PROD_STAGE_TERTIARY) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
806 splitatEdit->setItemData(6, false, Qt::UserRole -1);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
807 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
808
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
809 QLabel *vol_leftLabel = new QLabel(dialog);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
810 vol_leftLabel->setObjectName(QString::fromUtf8("vol_leftLabel"));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
811 vol_leftLabel->setGeometry(QRect(660, 140, 141, 20));
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
812 vol_leftLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
813 vol_leftLabel->setText(tr("Volume remaining:"));
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
814 vol_leftEdit = new QDoubleSpinBox(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
815 vol_leftEdit->setObjectName(QString::fromUtf8("vol_leftEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
816 vol_leftEdit->setGeometry(QRect(810, 140, 111, 24));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
817 vol_leftEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
818 vol_leftEdit->setReadOnly(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
819 vol_leftEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
820 vol_leftEdit->setMaximum(1000000.000000000000000);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
821 vol_leftEdit->setSuffix(tr(" L"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
822 vol_availEdit = new QDoubleSpinBox(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
823 vol_availEdit->setObjectName(QString::fromUtf8("vol_availEdit"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
824 vol_availEdit->setGeometry(QRect(170, 140, 111, 24));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
825 vol_availEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
826 vol_availEdit->setReadOnly(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
827 vol_availEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
828 vol_availEdit->setMaximum(1000000.000000000000000);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
829 vol_availEdit->setSuffix(tr(" L"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
830
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
831 const QStringList labels({tr("Split code"), tr("Split name"), tr("Split volume") });
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
832 splitTable = new QTableWidget(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
833 splitTable->setObjectName(QString::fromUtf8("splitTable"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
834 splitTable->setGeometry(QRect(30, 220, 961, 281));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
835 splitTable->setColumnCount(3);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
836 splitTable->setColumnWidth(0, 140); /* Split code */
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
837 splitTable->setColumnWidth(1, 680); /* Split name */
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
838 splitTable->setColumnWidth(2, 116); /* Split volume */
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
839 splitTable->setHorizontalHeaderLabels(labels);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
840 splitTable->verticalHeader()->hide();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
841 splitTable->setRowCount(0);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
842
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
843 split_addButton = new QPushButton(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
844 split_addButton->setObjectName(QString::fromUtf8("addButton"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
845 split_addButton->setGeometry(QRect(170, 180, 100, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
846 QIcon icon;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
847 icon.addFile(QString::fromUtf8("../resources/icons/silk/add.png"), QSize(), QIcon::Normal, QIcon::Off);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
848 split_addButton->setIcon(icon);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
849 split_addButton->setText(tr("Add"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
850
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
851 split_delButton = new QPushButton(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
852 split_delButton->setObjectName(QString::fromUtf8("delButton"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
853 split_delButton->setGeometry(QRect(660, 180, 100, 23));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
854 QIcon icon2;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
855 icon2.addFile(QString::fromUtf8("../resources/icons/silk/delete.png"), QSize(), QIcon::Normal, QIcon::Off);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
856 split_delButton->setIcon(icon2);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
857 split_delButton->setText(tr("Delete"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
858
268
72e8ade9aff2 Implemented the split table editor.
Michiel Broek <mbroek@mbse.eu>
parents: 267
diff changeset
859 split_show();
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
860 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
861 QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
862 connect(split_addButton, SIGNAL(clicked()), this, SLOT(split_add_clicked()));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
863 connect(split_delButton, SIGNAL(clicked()), this, SLOT(split_del_clicked()));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
864 connect(splitatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::split_splitat_changed);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
865 connect(splitTable, SIGNAL(cellChanged(int, int)), this, SLOT(split_table_changed(int, int)));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
866
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
867 dialog->setModal(true);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
868 dialog->exec();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
869 if (dialog->result() == QDialog::Accepted) {
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
870 doit = true;
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
871 }
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
872
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
873 disconnect(buttonBox, nullptr, nullptr, nullptr);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
874 disconnect(splitatEdit, nullptr, nullptr, nullptr);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
875 disconnect(splitTable, nullptr, nullptr, nullptr);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
876
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
877 if (! doit)
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
878 return;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
879 for (int i = 0; i < product->splits.size(); i++) {
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
880 Product *sp = new Product;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
881 if (DB_product::load(sp, this, product->record)) {
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
882 double factor = round((product->splits.at(i).size / vol_availEdit->value()) * 1000.0) / 1000.0;
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
883 qInfo() << "Split create part" << i + 1 << "code" << product->splits.at(i).code << "factor" << factor;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
884 sp->record = -1;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
885 sp->uuid = "";
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
886 sp->name = product->splits.at(i).name;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
887 sp->code = product->splits.at(i).code;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
888 sp->divide_type = product->divide_type;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
889 sp->divide_size = product->splits.at(i).size;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
890 sp->divide_factor = factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
891 sp->divide_parts = product->splits.size();
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
892 sp->divide_part = i + 1;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
893 /* Now adjust the volumes */
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
894 sp->brew_sparge_est = sp->brew_sparge_est * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
895 sp->brew_preboil_volume = sp->brew_preboil_volume * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
896 sp->brew_aboil_volume = sp->brew_aboil_volume * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
897 sp->brew_fermenter_volume = sp->brew_fermenter_volume * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
898 sp->brew_fermenter_extrawater = sp->brew_fermenter_extrawater * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
899 sp->brew_fermenter_tcloss = sp->brew_fermenter_tcloss * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
900 sp->package_volume = sp->package_volume * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
901 sp->package_infuse_amount = sp->package_infuse_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
902 sp->bottle_amount = sp->bottle_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
903 sp->bottle_priming_water = sp->bottle_priming_water * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
904 sp->keg_amount = sp->keg_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
905 sp->keg_priming_water = sp->keg_priming_water * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
906 sp->batch_size = sp->batch_size * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
907 sp->boil_size = sp->boil_size * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
908 sp->sparge_volume = sp->sparge_volume * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
909 sp->sparge_acid_amount = sp->sparge_acid_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
910 sp->w1_amount = sp->w1_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
911 sp->w2_amount = sp->w2_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
912 sp->wg_amount = sp->wg_amount * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
913 sp->prop_volume[0] = sp->prop_volume[0] * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
914 sp->prop_volume[1] = sp->prop_volume[1] * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
915 sp->prop_volume[2] = sp->prop_volume[2] * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
916 sp->prop_volume[3] = sp->prop_volume[3] * factor;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
917 for (int j = 0; j < sp->fermentables.size(); j++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
918 sp->fermentables[j].amount = round(sp->fermentables.at(j).amount * factor * 100000) / 100000;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
919 }
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
920 for (int j = 0; j < sp->hops.size(); j++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
921 sp->hops[j].amount = round(sp->hops.at(j).amount * factor * 100000) / 100000;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
922 }
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
923 for (int j = 0; j < sp->miscs.size(); j++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
924 sp->miscs[j].amount = round(sp->miscs.at(j).amount * factor * 100000) / 100000;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
925 }
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
926 for (int j = 0; j < sp->yeasts.size(); j++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
927 sp->yeasts[j].amount = round(sp->yeasts.at(j).amount * factor * 100000) / 100000;
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
928 }
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
929 for (int j = 0; j < sp->mashs.size(); j++) {
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
930 sp->mashs[j].step_volume = round(sp->mashs.at(j).step_volume * factor * 100) / 100;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
931 sp->mashs[j].step_infuse_amount = round(sp->mashs.at(j).step_infuse_amount * factor * 100) / 100;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
932 }
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
933 doit = DB_product::save(sp, this);
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
934 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
935 delete sp;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
936 if (! doit)
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
937 break; // If errors
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
938 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
939
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
940 if (doit) { // Still ok?
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
941 Product *sp = new Product;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
942 if (DB_product::load(sp, this, product->record)) {
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
943 double factor = round((vol_leftEdit->value() / vol_availEdit->value()) * 1000.0) / 1000.0;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
944 qInfo() << "Split update main" << sp->code << "factor" << factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
945 sp->divide_type = product->divide_type;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
946 sp->divide_size = vol_leftEdit->value();
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
947 sp->divide_factor = factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
948 sp->divide_parts = product->splits.size();
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
949 sp->divide_part = 0;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
950 /* Now adjust the volumes */
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
951 sp->brew_sparge_est = sp->brew_sparge_est * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
952 sp->brew_preboil_volume = sp->brew_preboil_volume * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
953 sp->brew_aboil_volume = sp->brew_aboil_volume * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
954 sp->brew_fermenter_volume = sp->brew_fermenter_volume * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
955 sp->brew_fermenter_extrawater = sp->brew_fermenter_extrawater * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
956 sp->brew_fermenter_tcloss = sp->brew_fermenter_tcloss * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
957 sp->package_volume = sp->package_volume * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
958 sp->package_infuse_amount = sp->package_infuse_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
959 sp->bottle_amount = sp->bottle_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
960 sp->bottle_priming_water = sp->bottle_priming_water * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
961 sp->keg_amount = sp->keg_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
962 sp->keg_priming_water = sp->keg_priming_water * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
963 sp->batch_size = sp->batch_size * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
964 sp->boil_size = sp->boil_size * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
965 sp->sparge_volume = sp->sparge_volume * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
966 sp->sparge_acid_amount = sp->sparge_acid_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
967 sp->w1_amount = sp->w1_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
968 sp->w2_amount = sp->w2_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
969 sp->wg_amount = sp->wg_amount * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
970 sp->prop_volume[0] = sp->prop_volume[0] * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
971 sp->prop_volume[1] = sp->prop_volume[1] * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
972 sp->prop_volume[2] = sp->prop_volume[2] * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
973 sp->prop_volume[3] = sp->prop_volume[3] * factor;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
974 for (int j = 0; j < sp->fermentables.size(); j++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
975 sp->fermentables[j].amount = round(sp->fermentables.at(j).amount * factor * 100000) / 100000;
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
976 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
977 for (int j = 0; j < sp->hops.size(); j++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
978 sp->hops[j].amount = round(sp->hops.at(j).amount * factor * 100000) / 100000;
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
979 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
980 for (int j = 0; j < sp->miscs.size(); j++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
981 sp->miscs[j].amount = round(sp->miscs.at(j).amount * factor * 100000) / 100000;
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
982 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
983 for (int j = 0; j < sp->yeasts.size(); j++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
984 sp->yeasts[j].amount = round(sp->yeasts.at(j).amount * factor * 100000) / 100000;
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
985 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
986 for (int j = 0; j < sp->mashs.size(); j++) {
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
987 sp->mashs[j].step_volume = round(sp->mashs.at(j).step_volume * factor * 100) / 100;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
988 sp->mashs[j].step_infuse_amount = round(sp->mashs.at(j).step_infuse_amount * factor * 100) / 100;
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
989 }
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
990 doit = DB_product::save(sp, this);
270
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
991 }
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
992 delete sp;
a0f72d7ace1f Added create splitted batches. Fixed rounding amount values at several places.
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
993 }
271
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
994 if (doit)
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
995 qInfo() << "Split is finished and ok";
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
996 else
f56c0dff0a3d Added the main record update to the product splitting. Block edit of the product code if the product is splitted.
Michiel Broek <mbroek@mbse.eu>
parents: 270
diff changeset
997 qWarning() << "Split errors were found";
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
998
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
999 /* Make sure the product editor is closed after splitting */
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1000 this->close();
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1001 this->setResult(1);
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1002 }
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1003
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1004
237
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1005 void EditProduct::on_exportButton_clicked()
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1006 {
243
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1007 QDialog* dialog = new QDialog(this);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1008 dialog->setWindowTitle(tr("Export choices"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1009 dialog->setObjectName(QString::fromUtf8("Dialog"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1010 dialog->resize(400, 179);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1011 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1012 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1013 buttonBox->setGeometry(QRect(280, 20, 81, 61));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1014 buttonBox->setOrientation(Qt::Vertical);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1015 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1016
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1017 QRadioButton *beerxmlButton = new QRadioButton(dialog);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1018 beerxmlButton->setObjectName(QString::fromUtf8("beerxmlButton"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1019 beerxmlButton->setGeometry(QRect(50, 20, 171, 21));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1020 beerxmlButton->setText(tr("Export to beerXML"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1021 QRadioButton *copproductButton = new QRadioButton(dialog);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1022 copproductButton->setObjectName(QString::fromUtf8("copproductButton"));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1023 copproductButton->setGeometry(QRect(50, 50, 171, 21));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1024 copproductButton->setText(tr("Copy to product"));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1025 QRadioButton *coprecipeButton = new QRadioButton(dialog);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1026 coprecipeButton->setObjectName(QString::fromUtf8("coprecipeButton"));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1027 coprecipeButton->setGeometry(QRect(50, 80, 171, 21));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1028 coprecipeButton->setText(tr("Copy to recipe"));
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
1029 QRadioButton *toforumButton = new QRadioButton(dialog);
243
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1030 toforumButton->setObjectName(QString::fromUtf8("toforumButton"));
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
1031 toforumButton->setGeometry(QRect(50, 110, 171, 21));
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
1032 toforumButton->setText(tr("Export to forum"));
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1033 QRadioButton *splitButton = new QRadioButton(dialog);
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1034 splitButton->setObjectName(QString::fromUtf8("splitButton"));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1035 splitButton->setGeometry(QRect(50, 140, 171, 21));
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1036 splitButton->setText(tr("Split this batch"));
269
f92db2eabd0d Disable split product if already splitted, or if stage is after last possible splitpoint.
Michiel Broek <mbroek@mbse.eu>
parents: 268
diff changeset
1037 if ((product->divide_type > 0) || (product->stage > PROD_STAGE_TERTIARY))
f92db2eabd0d Disable split product if already splitted, or if stage is after last possible splitpoint.
Michiel Broek <mbroek@mbse.eu>
parents: 268
diff changeset
1038 splitButton->setEnabled(false); // Disable if already splitted or past last possible splitpoint.
243
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1039
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1040 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1041 QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1042
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1043 dialog->setModal(true);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1044 dialog->exec();
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1045 if (dialog->result() == QDialog::Accepted) {
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1046 if (beerxmlButton->isChecked())
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1047 exportBeerXML();
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1048 if (copproductButton->isChecked())
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1049 copyProduct();
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1050 if (coprecipeButton->isChecked())
265
df17db1484f6 Added export product to recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
1051 copyRecipe();
266
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
1052 if (toforumButton->isChecked())
5f0782149028 Added export product to forum.
Michiel Broek <mbroek@mbse.eu>
parents: 265
diff changeset
1053 toforumProduct();
267
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1054 if (splitButton->isChecked())
8af232524e64 Added the framework for splitting batches.
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
1055 splitProduct();
243
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1056 }
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1057
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1058 disconnect(buttonBox, nullptr, nullptr, nullptr);
237
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1059 }
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1060
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1061
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1062 void EditProduct::on_printButton_clicked()
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1063 {
243
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1064 QDialog* dialog = new QDialog(this);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1065 dialog->setWindowTitle(tr("Printer report"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1066 dialog->setObjectName(QString::fromUtf8("Dialog"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1067 dialog->resize(400, 101);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1068 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1069 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1070 buttonBox->setGeometry(QRect(280, 20, 81, 61));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1071 buttonBox->setOrientation(Qt::Vertical);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1072 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1073
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1074 QRadioButton *recipeButton = new QRadioButton(dialog);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1075 recipeButton->setObjectName(QString::fromUtf8("recipeButton"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1076 recipeButton->setGeometry(QRect(50, 20, 171, 21));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1077 recipeButton->setText(tr("Print recipe"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1078 QRadioButton *checklistButton = new QRadioButton(dialog);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1079 checklistButton->setObjectName(QString::fromUtf8("checklistButton"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1080 checklistButton->setGeometry(QRect(50, 50, 171, 21));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1081 checklistButton->setText(tr("Print checklist"));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1082
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1083 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1084 QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1085
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1086 dialog->setModal(true);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1087 dialog->exec();
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1088 if (dialog->result() == QDialog::Accepted) {
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1089 if (checklistButton->isChecked())
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1090 PrinterDialog(PR_CHECKLIST, -1, this);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1091 if (recipeButton->isChecked())
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1092 PrinterDialog(PR_PRODUCT, -1, this);
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1093 }
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1094
84dc3c1c2d02 Added print and export choices popups. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1095 disconnect(buttonBox, nullptr, nullptr, nullptr);
237
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1096 }
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1097
f1032191578b Added most of print product
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
1098

mercurial