# HG changeset patch # User Michiel Broek # Date 1654594195 -7200 # Node ID 5f0782149028982707bdc8db5c500b1a63c0c5a2 # Parent df17db1484f68b8df57615c36dd5c06c1d01bf74 Added export product to forum. diff -r df17db1484f6 -r 5f0782149028 src/EditProduct.cpp --- a/src/EditProduct.cpp Tue Jun 07 11:05:23 2022 +0200 +++ b/src/EditProduct.cpp Tue Jun 07 11:29:55 2022 +0200 @@ -20,6 +20,7 @@ #include "../ui/ui_EditProduct.h" #include "Utils.h" #include "global.h" +#include "config.h" #include "database/db_product.h" #include "database/db_recipe.h" diff -r df17db1484f6 -r 5f0782149028 src/EditProduct.h --- a/src/EditProduct.h Tue Jun 07 11:05:23 2022 +0200 +++ b/src/EditProduct.h Tue Jun 07 11:29:55 2022 +0200 @@ -14,6 +14,7 @@ #include #include #include +#include #include "global.h" diff -r df17db1484f6 -r 5f0782149028 src/EditProductExport.cpp --- a/src/EditProductExport.cpp Tue Jun 07 11:05:23 2022 +0200 +++ b/src/EditProductExport.cpp Tue Jun 07 11:29:55 2022 +0200 @@ -425,6 +425,156 @@ void EditProduct::toforumProduct() { + const QStringList recipetypes({ "Extract", "Partial Mash", "All Grain" }); + const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); + const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" }); + const QStringList fermentable_added({ "Maischen", "Koken", "Hoofd/nagisting", "Lageren", "Bottelen", "Fusten" }); + const QStringList hop_forms({ "Pellet", "Plug", "Bloemen", "Verse hop", "Cryo" }); + 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]" + product->name + "[/data][/row]\n"); + memo.append("[row][data]Bier stijl[/data][data]" + product->st_name + "[/data][/row]\n"); + memo.append("[row][data]Recept type[/data][data]" + recipetypes[product->type] + "[/data][/row]\n"); + memo.append("[row][data]Batch grootte[/data][data]" + QString::number(product->batch_size, 'f', 1) + " L[/data][/row]\n"); + memo.append("[row][data]Kooktijd[/data][data]" + QString::number(product->boil_time, 'f', 0) + " minuten[/data][/row]\n"); + memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(product->efficiency, 'f', 1) + "%[/data][/row]\n"); + memo.append("[row][data]Geschatte begin densiteit[/data][data]" + QString::number(product->est_og, 'f', 3) + " SG[/data][/row]\n"); + memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(product->est_fg, 'f', 3) + " SG[/data][/row]\n"); + memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(product->est_abv, 'f', 1) + "%[/data][/row]\n"); + memo.append("[row][data]Kleur (" + color_method[product->color_method] + ")[/data][data]" + QString::number(product->est_color, 'f', 0) + " EBC[/data][/row]\n"); + memo.append("[row][data]Bitterheid (" + ibu_method[product->ibu_method] + ")[/data][data]" + QString::number(product->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 < product->fermentables.size(); i++) { + memo.append("[row][data]" + product->fermentables.at(i).f_name + " (" + product->fermentables.at(i).f_supplier + ")[/data]"); + memo.append("[data]" + QString::number(product->fermentables.at(i).f_color) + "[/data]"); + memo.append("[data]" + QString::number(product->fermentables.at(i).f_amount, 'f', 3) + "[/data]"); + memo.append("[data]" + QString::number(product->fermentables.at(i).f_percentage, 'f', 1) + "[/data]"); + memo.append("[data]" + fermentable_added[product->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 < product->hops.size(); i++) { + double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, + product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, + product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); + memo.append("[row][data]" + product->hops.at(i).h_name + " (" + product->hops.at(i).h_origin + ")[/data]"); + memo.append("[data]" + hop_forms[product->hops.at(i).h_form] + "[/data]"); + memo.append("[data]" + QString::number(product->hops.at(i).h_alpha, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->hops.at(i).h_amount * 1000, 'f', 2) + "[/data]"); + if (product->hops.at(i).h_useat == HOP_USEAT_BOIL || product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) + memo.append("[data]" + hop_use[product->hops.at(i).h_useat] + " " + QString::number(product->hops.at(i).h_time) + " minuten[/data][/row]\n"); + else if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) + memo.append("[data]" + hop_use[product->hops.at(i).h_useat] + " " + QString::number(product->hops.at(i).h_time / 1440) + " dagen[/data][/row]\n"); + else + memo.append("[data]" + hop_use[product->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 < product->miscs.size(); i++) { + memo.append("[row][data]" + product->miscs.at(i).m_name + "[/data]"); + memo.append("[data]" + misc_type[product->miscs.at(i).m_type] + "[/data]"); + if (product->miscs.at(i).m_use_use == MISC_USES_BOIL) + memo.append("[data]" + misc_use[product->miscs.at(i).m_use_use] + " " + QString::number(product->miscs.at(i).m_time) + " min[/data]"); + else + memo.append("[data]" + misc_use[product->miscs.at(i).m_use_use] + "[/data]"); + memo.append("[data]"+QString::number(product->miscs.at(i).m_amount * 1000, 'f', 2)+((product->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 < product->yeasts.size(); i++) { + memo.append("[row][data]" + product->yeasts.at(i).y_laboratory + " " + product->yeasts.at(i).y_product_id + "[/data]"); + memo.append("[data]" + product->yeasts.at(i).y_name + "[/data]"); + memo.append("[data]" + yeast_use[product->yeasts.at(i).y_use] + "[/data]"); + memo.append("[data]" + yeast_form[product->yeasts.at(i).y_form] + "[/data]"); + if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) + memo.append("[data]" + QString::number(product->yeasts.at(i).y_amount, 'f', 0) + " pak[/data][/row]\n"); + else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY || product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) + memo.append("[data]" + QString::number(product->yeasts.at(i).y_amount * 1000, 'f', 1) + " gr[/data][/row]\n"); + else + memo.append("[data]" + QString::number(product->yeasts.at(i).y_amount * 1000, 'f', 0) + " ml[/data][/row]\n"); + } + memo.append("[/tabular]\n"); + if (product->starter_enable) { + double sv = 0; + for (int i = 0; i < 4; i++) { + if ((product->prop_volume[i] > 0) && (product->prop_volume[i] > sv)) + sv = product->prop_volume[i]; + } + memo.append("Maak een giststarter van " + QString::number(sv, 'f', 1) + " liter.\n"); + } + memo.append("\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 < product->mashs.size(); i++) { + memo.append("[row][data]" + product->mashs.at(i).step_name + "[/data]"); + if (product->mashs.at(i).step_type != 1) + memo.append("[data]" + step_type[product->mashs.at(i).step_type]+" "+QString::number(product->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]"); + else + memo.append("[data]" + step_type[product->mashs.at(i).step_type] + "[/data]"); + memo.append("[data]" + QString::number(product->mashs.at(i).step_temp, 'f', 1) + " °C[/data]"); + memo.append("[data]" + QString::number(product->mashs.at(i).step_time, 'f', 0) + " min[/data]"); + memo.append("[data]" + QString::number(product->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n"); + } + 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 (product->w2_name != "" && product->w2_amount > 0) { + memo.append("[row][data]Maischwater 1[/data][data]" + product->w1_name + " " + QString::number(product->w1_amount, 'f', 1) + " Liter[/data][/row]\n"); + memo.append("[row][data]Maischwater 2[/data][data]" + product->w2_name + " " + QString::number(product->w2_amount, 'f', 1) + " Liter[/data][/row]\n"); + } else { + memo.append("[row][data]Maischwater[/data][data]" + product->w1_name + " " + QString::number(product->w1_amount, 'f', 1) + " Liter[/data][/row]\n"); + } + memo.append("[row][data]Maischwater aanzuren tot[/data][data]" + QString::number(product->mash_ph, 'f', 1) + " pH[/data][/row]\n"); + memo.append("[row][data]Spoelwater geschat[/data][data]" + QString::number(product->brew_sparge_est, 'f', 1) + " Liter[/data][/row]\n"); + memo.append("[row][data]Spoelwater temperatuur[/data][data]" + QString::number(product->sparge_temp, 'f', 1) + " °C[/data][/row]\n"); + memo.append("[row][data]Spoelwater aanzuren tot[/data][data]" + QString::number(product->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(product->wb_calcium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->wb_magnesium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->wb_sodium, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->wb_total_alkalinity * 61 / 50, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->wb_chloride, 'f', 1) + "[/data]"); + memo.append("[data]" + QString::number(product->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.")); } @@ -461,10 +611,10 @@ copy_recipeButton->setObjectName(QString::fromUtf8("copy_recipeButton")); copy_recipeButton->setGeometry(QRect(50, 80, 171, 21)); copy_recipeButton->setText(tr("Copy to recipe")); -/* QRadioButton *toforumButton = new QRadioButton(dialog); + QRadioButton *toforumButton = new QRadioButton(dialog); toforumButton->setObjectName(QString::fromUtf8("toforumButton")); - toforumButton->setGeometry(QRect(50, 140, 171, 21)); - toforumButton->setText(tr("Export to forum")); */ + toforumButton->setGeometry(QRect(50, 110, 171, 21)); + toforumButton->setText(tr("Export to forum")); QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); @@ -478,6 +628,8 @@ copyProduct(); if (copy_recipeButton->isChecked()) copyRecipe(); + if (toforumButton->isChecked()) + toforumProduct(); } disconnect(buttonBox, nullptr, nullptr, nullptr);