diff -r c136bd15b084 -r cfba041bdaee src/EditRecipeExport.cpp --- a/src/EditRecipeExport.cpp Sun Jun 05 21:10:06 2022 +0200 +++ b/src/EditRecipeExport.cpp Mon Jun 06 13:04:27 2022 +0200 @@ -45,6 +45,7 @@ return; } + qInfo() << "Recipe to beerXML" << fileName; QFile file(fileName); file.open(QIODevice::WriteOnly); @@ -267,6 +268,7 @@ dup = recipe; dup->record = -1; dup->uuid = ""; + dup->name.append(" [duplicate]"); qDebug() << dup->record << dup->name; if (DB_recipe::save(dup, this)) { QMessageBox::information(this, tr("Copy Recipe"), tr("Copy Recipe export ready.")); @@ -365,17 +367,17 @@ p->taste_notes = p->taste_color = p->taste_transparency = p->taste_head = ""; p->taste_aroma = p->taste_taste = p->taste_mouthfeel = p->taste_aftertaste = ""; - p->sparge_temp = 80; - p->sparge_ph = 5.4; - p->sparge_volume = 8; - p->sparge_source = 0; - p->sparge_acid_type = 0; - p->sparge_acid_perc = 80; - p->sparge_acid_amount = 0; - p->mash_ph = 5.4; - p->mash_name = ""; + p->sparge_temp = recipe->sparge_temp; + p->sparge_ph = recipe->sparge_ph; + p->sparge_volume = recipe->sparge_volume; + p->sparge_source = recipe->sparge_source; + p->sparge_acid_type = recipe->sparge_acid_type; + p->sparge_acid_perc = recipe->sparge_acid_perc; + p->sparge_acid_amount = recipe->sparge_acid_amount; + p->mash_ph = recipe->mash_ph; + p->mash_name = recipe->mash_name; - p->calc_acid = true; + p->calc_acid = recipe->calc_acid; p->w1_name = recipe->w1_name; p->w1_amount = recipe->w1_amount; p->w1_calcium = recipe->w1_calcium; @@ -437,7 +439,150 @@ } -void EditRecipe::toforumRecipe() { } +void EditRecipe::toforumRecipe() +{ + const QStringList recipetypes({ "Extract", "Partial Mash", "All Grain" }); + const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); + const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" }); + const QStringList fermentable_added({ "Maischen", "Koken", "Hoofd/nagisting", "Lageren", "Bottelen", "Fusten" }); + const QStringList hop_forms({ "Pellet", "Plug", "Bloemen", "Verse hop", "Cryo" }); + const QStringList hop_use({ "Maischen", "First wort", "Koken", "Vlamuit", "Whirlpool", "Drooghop" }); + const QStringList misc_type({ "Spice", "Herb", "Smaakstof", "Klaren", "Brouwzout", "Gist voeding", "Overig" }); + const QStringList misc_use({ "Starter", "Maischen", "Koken", "Hoofdgisting", "Nagisting", "Bottelen" }); + const QStringList yeast_form({ "Vloeibaar", "Droog", "Schuine buis", "Opkweek", "Ingevroren", "Flesbodem", "Gedroogd" }); + const QStringList yeast_use({ "Hoofdgisting", "Nagisting", "Lageren", "Bottelen", "Fusten" }); + const QStringList step_type({ "Infusie", "Verwarmen", "Decoctie" }); + + QString memo = QString("[u][b]BMSapp v"); + memo.append(VERSIONSTRING); // For some stupid reason this must be on it's own. + memo.append(" - Datum export: " + QDate::currentDate().toString("dd-MMM-yyyy") + "[/b][/u]\n\n\n"); + memo.append("[u][b]Basis[/b][/u]\n[tabular]\n"); + memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n"); + memo.append("[row][data]Bier naam[/data][data]" + recipe->name + "[/data][/row]\n"); + memo.append("[row][data]Bier stijl[/data][data]" + recipe->st_name + "[/data][/row]\n"); + memo.append("[row][data]Recept type[/data][data]" + recipetypes[recipe->type] + "[/data][/row]\n"); + memo.append("[row][data]Batch grootte[/data][data]" + QString::number(recipe->batch_size, 'f', 1) + " L[/data][/row]\n"); + memo.append("[row][data]Kooktijd[/data][data]" + QString::number(recipe->boil_time, 'f', 0) + " minuten[/data][/row]\n"); + memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(recipe->efficiency, 'f', 1) + "%[/data][/row]\n"); + memo.append("[row][data]Geschatte begin densiteit[/data][data]" + QString::number(recipe->est_og, 'f', 3) + " SG[/data][/row]\n"); + memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(recipe->est_fg, 'f', 3) + " SG[/data][/row]\n"); + memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(recipe->est_abv, 'f', 1) + "%[/data][/row]\n"); + memo.append("[row][data]Kleur (" + color_method[recipe->color_method] + ")[/data][data]" + QString::number(recipe->est_color, 'f', 0) + " EBC[/data][/row]\n"); + memo.append("[row][data]Bitterheid (" + ibu_method[recipe->ibu_method] + ")[/data][data]" + QString::number(recipe->est_ibu, 'f', 1) + " IBU[/data][/row]\n"); + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Vergistbare ingrediënten[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Mout, granen en suikers[/head][head]EBC[/head][head]Gewicht kg[/head][head]%[/head][head]Gebruik tijdens[/head]\n"); + for (int i = 0; i < recipe->fermentables.size(); i++) { + memo.append("[row][data]" + recipe->fermentables.at(i).f_name + " (" + recipe->fermentables.at(i).f_supplier + ")[/data]"); + memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_color) + "[/data]"); + memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_amount, 'f', 3) + "[/data]"); + memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_percentage, 'f', 1) + "[/data]"); + memo.append("[data]" + fermentable_added[recipe->fermentables.at(i).f_added] + "[/data][/row]\n"); + } + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Hop[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Hop[/head][head]Vorm[/head][head]Alpha[/head][head]IBU[/head][head]Gram[/head][head]Toevoegen moment[/head]\n"); + for (int i = 0; i < recipe->hops.size(); i++) { + double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, + recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, + 0, recipe->hops.at(i).h_time, 0, recipe->boil_time); + memo.append("[row][data]" + recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")[/data]"); + memo.append("[data]" + hop_forms[recipe->hops.at(i).h_form] + "[/data]"); + memo.append("[data]" + QString::number(recipe->hops.at(i).h_alpha, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->hops.at(i).h_amount * 1000, 'f', 2) + "[/data]"); + if (recipe->hops.at(i).h_useat == HOP_USEAT_BOIL || recipe->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) + memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time) + " minuten[/data][/row]\n"); + else if (recipe->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) + memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time / 1440) + " dagen[/data][/row]\n"); + else + memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + "[/data][/row]\n"); + } + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Diversen[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Specerij, kruid, brouwzout[/head][head]Type grondstof[/head][head]Gebruik tijdens[/head][head]Hoeveel[/head]\n"); + for (int i = 0; i < recipe->miscs.size(); i++) { + memo.append("[row][data]" + recipe->miscs.at(i).m_name + "[/data]"); + memo.append("[data]" + misc_type[recipe->miscs.at(i).m_type] + "[/data]"); + if (recipe->miscs.at(i).m_use_use == MISC_USES_BOIL) + memo.append("[data]" + misc_use[recipe->miscs.at(i).m_use_use] + " " + QString::number(recipe->miscs.at(i).m_time) + " min[/data]"); + else + memo.append("[data]" + misc_use[recipe->miscs.at(i).m_use_use] + "[/data]"); + memo.append("[data]"+QString::number(recipe->miscs.at(i).m_amount * 1000, 'f', 2)+((recipe->miscs.at(i).m_amount_is_weight)?" gr":" ml")+"[/data][/row]\n"); + } + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Gist[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Gistlab en code[/head][head]Omschrijving[/head][head]Gebruik[/head][head]Vorm[/head][head]Hoeveel[/head]\n"); + for (int i = 0; i < recipe->yeasts.size(); i++) { + memo.append("[row][data]" + recipe->yeasts.at(i).y_laboratory + " " + recipe->yeasts.at(i).y_product_id + "[/data]"); + memo.append("[data]" + recipe->yeasts.at(i).y_name + "[/data]"); + memo.append("[data]" + yeast_use[recipe->yeasts.at(i).y_use] + "[/data]"); + memo.append("[data]" + yeast_form[recipe->yeasts.at(i).y_form] + "[/data]"); + if (recipe->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) + memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount, 'f', 0) + " pak[/data][/row]\n"); + else if (recipe->yeasts.at(i).y_form == YEAST_FORMS_DRY || recipe->yeasts.at(i).y_form == YEAST_FORMS_DRIED) + memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount * 1000, 'f', 1) + " gr[/data][/row]\n"); + else + memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount * 1000, 'f', 0) + " ml[/data][/row]\n"); + } + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Maischen[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Maisch stap[/head][head]Stap type[/head][head]Temperatuur[/head][head]Rust tijd[/head][head]Opwarm tijd[/head]\n"); + for (int i = 0; i < recipe->mashs.size(); i++) { + memo.append("[row][data]" + recipe->mashs.at(i).step_name + "[/data]"); + if (recipe->mashs.at(i).step_type != 1) + memo.append("[data]" + step_type[recipe->mashs.at(i).step_type]+" "+QString::number(recipe->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]"); + else + memo.append("[data]" + step_type[recipe->mashs.at(i).step_type] + "[/data]"); + memo.append("[data]" + QString::number(recipe->mashs.at(i).step_temp, 'f', 1) + " °C[/data]"); + memo.append("[data]" + QString::number(recipe->mashs.at(i).step_time, 'f', 0) + " min[/data]"); + memo.append("[data]" + QString::number(recipe->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n"); + } + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Brouwwater[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n"); + if (recipe->w2_name != "" && recipe->w2_amount > 0) { + memo.append("[row][data]Maischwater 1[/data][data]" + recipe->w1_name + " " + QString::number(recipe->w1_amount, 'f', 1) + " Liter[/data][/row]\n"); + memo.append("[row][data]Maischwater 2[/data][data]" + recipe->w2_name + " " + QString::number(recipe->w2_amount, 'f', 1) + " Liter[/data][/row]\n"); + } else { + memo.append("[row][data]Maischwater[/data][data]" + recipe->w1_name + " " + QString::number(recipe->w1_amount, 'f', 1) + " Liter[/data][/row]\n"); + } + memo.append("[row][data]Maischwater aanzuren tot[/data][data]" + QString::number(recipe->mash_ph, 'f', 1) + " pH[/data][/row]\n"); + memo.append("[row][data]Spoelwater geschat[/data][data]" + QString::number(recipe->sparge_volume, 'f', 1) + " Liter[/data][/row]\n"); + memo.append("[row][data]Spoelwater temperatuur[/data][data]" + QString::number(recipe->sparge_temp, 'f', 1) + " °C[/data][/row]\n"); + memo.append("[row][data]Spoelwater aanzuren tot[/data][data]" + QString::number(recipe->sparge_ph, 'f', 1) + " pH[/data][/row]\n"); + memo.append("[/tabular]\n\n"); + + memo.append("[u][b]Waterprofiel behandeld water[/b][/u]\n"); + memo.append("[tabular]\n"); + memo.append("[head]Ca[/head][head]Mg[/head][head]Na[/head][head]HCO3[/head][head]Cl[/head][head]SO4[/head]\n"); + memo.append("[row][data]" + QString::number(recipe->wb_calcium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->wb_magnesium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->wb_sodium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->wb_total_alkalinity * 61 / 50, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->wb_chloride, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(recipe->wb_sulfate, 'f', 1) + "[/data][/row]\n"); + memo.append("[/tabular]\n\n"); + + qDebug().noquote() << memo; + QGuiApplication::clipboard()->setText(memo, QClipboard::Clipboard); + QGuiApplication::clipboard()->setText(memo, QClipboard::Selection); + + QMessageBox::information(this, tr("Export to forum"), tr("The recipe and all data are copied to the clipboard.\n" + "You can \"paste\" this data in the forum screen in your web browser.")); +} void EditRecipe::on_exportButton_clicked() { @@ -483,6 +628,8 @@ copyRecipe(); if (copy_productButton->isChecked()) copyProduct(); + if (toforumButton->isChecked()) + toforumRecipe(); } disconnect(buttonBox, nullptr, nullptr, nullptr);