Tue, 07 Jun 2022 11:05:23 +0200
Added export product to recipe.
/** * EditProduct.cpp is part of bmsapp. * * Export product. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ void EditProduct::exportBeerXML() { qDebug() << "export"; const QStringList styletype({ "Lager", "Ale", "Mead", "Wheat", "Mixed", "Cider" }); const QStringList producttypes({ "Extract", "Partial Mash", "All Grain" }); const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" }); const QStringList hop_types({ "Bittering", "Aroma", "Both" }); const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet" }); /* "Leaf Wet", "Cryo" */ /* We use more hop forms then beerxml knows about, so we send known names */ /* instead of what we internally use. */ const QStringList hop_use({ "Mash", "First wort", "Boil", "Aroma", "Whirlpool", "Dry hop" }); const QStringList fermentable_type({ "Grain", "Sugar", "Extract", "Dry extract", "Adjunct" }); const QStringList fermentable_graintype({ "Base", "Roast", "Crystal", "Kilned", "Sour malt", "Special", "No malt" }); const QStringList yeast_type({ "Lager", "Ale", "Wheat", "Wine", "Champagne", "Other", "Other", "Other", "Other", "Other" }); const QStringList yeast_form({ "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dry" }); const QStringList yeast_use({ "Primary", "Secondary", "Tertiary", "Bottle" }); const QStringList misc_type({ "Spice", "Herb", "Flavor", "Fining", "Water agent", "Yeast nutrient", "Other" }); const QStringList misc_use({ "Starter", "Mash", "Boil", "Primary", "Secondary", "Bottling" }); const QStringList step_type({ "Infusion", "Temperature", "Decoction" }); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/" + product->code + " " + product->name + ".xml", tr("Files (*.xml)")); if (fileName == 0) { QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); return; } QFile file(fileName); file.open(QIODevice::WriteOnly); QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); xmlWriter->writeStartDocument(); xmlWriter->setAutoFormatting(true); xmlWriter->setAutoFormattingIndent(1); xmlWriter->writeStartElement("RECIPES"); xmlWriter->writeStartElement("RECIPE"); /* * Product basics */ xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->name); if (product->notes != "") xmlWriter->writeTextElement("NOTES", product->notes); xmlWriter->writeTextElement("TYPE", producttypes[product->type]); xmlWriter->writeTextElement("BREWER", "Anonymous"); xmlWriter->writeTextElement("BATCH_SIZE", QString::number(product->batch_size, 'f', 4)); xmlWriter->writeTextElement("BOIL_SIZE", QString::number(product->boil_size, 'f', 4)); xmlWriter->writeTextElement("BOIL_TIME", QString::number(product->boil_time, 'f', 3)); xmlWriter->writeTextElement("EFFICIENCY", QString::number(product->efficiency, 'f', 4)); if (product->og > 0.9) xmlWriter->writeTextElement("OG", QString::number(product->og, 'f', 3)); if (product->fg > 0.9) xmlWriter->writeTextElement("FG", QString::number(product->fg, 'f', 3)); xmlWriter->writeTextElement("EST_OG", QString::number(product->est_og, 'f', 3)); xmlWriter->writeTextElement("EST_FG", QString::number(product->est_fg, 'f', 3)); if (product->est_abv > 0) xmlWriter->writeTextElement("EST_ABV", QString::number(product->est_abv, 'f', 1)); if (product->est_color > 0) { xmlWriter->writeTextElement("EST_COLOR", QString::number(Utils::ebc_to_srm(product->est_color), 'f', 6)); xmlWriter->writeTextElement("COLOR_METHOD", color_method[product->color_method]); } if (product->est_ibu > 0) { xmlWriter->writeTextElement("EST_IBU", QString::number(product->est_ibu, 'f', 1)); xmlWriter->writeTextElement("IBU_METHOD", ibu_method[product->ibu_method]); } xmlWriter->writeTextElement("BMS_COOLING_TO", QString::number(product->brew_cooling_to, 'f', 1)); xmlWriter->writeStartElement("STYLE"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->st_name); xmlWriter->writeTextElement("CATEGORY", product->st_category); xmlWriter->writeTextElement("CATEGORY_NUMBER", QString::number(product->st_category_number, 'f', 0)); xmlWriter->writeTextElement("STYLE_LETTER", product->st_letter); xmlWriter->writeTextElement("STYLE_GUIDE", product->st_guide); xmlWriter->writeTextElement("TYPE", styletype[product->st_type]); xmlWriter->writeTextElement("OG_MIN", QString::number(product->st_og_min, 'f', 3)); xmlWriter->writeTextElement("OG_MAX", QString::number(product->st_og_max, 'f', 3)); xmlWriter->writeTextElement("FG_MIN", QString::number(product->st_fg_min, 'f', 3)); xmlWriter->writeTextElement("FG_MAX", QString::number(product->st_fg_max, 'f', 3)); xmlWriter->writeTextElement("IBU_MIN", QString::number(product->st_ibu_min, 'f', 0)); xmlWriter->writeTextElement("IBU_MAX", QString::number(product->st_ibu_max, 'f', 0)); xmlWriter->writeTextElement("COLOR_MIN", QString::number(Utils::ebc_to_srm(product->st_color_min), 'f', 2)); xmlWriter->writeTextElement("COLOR_MAX", QString::number(Utils::ebc_to_srm(product->st_color_max), 'f', 2)); xmlWriter->writeTextElement("CARB_MIN", QString::number(product->st_carb_min, 'f', 1)); xmlWriter->writeTextElement("CARB_MAX", QString::number(product->st_carb_max, 'f', 1)); xmlWriter->writeTextElement("ABV_MIN", QString::number(product->st_abv_min, 'f', 1)); xmlWriter->writeTextElement("ABV_MAX", QString::number(product->st_abv_max, 'f', 1)); xmlWriter->writeEndElement(); // STYLE xmlWriter->writeStartElement("EQUIPMENT"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->eq_name); xmlWriter->writeTextElement("NOTES", product->eq_notes); xmlWriter->writeTextElement("BATCH_SIZE", QString::number(product->eq_batch_size, 'f', 2)); xmlWriter->writeTextElement("BOIL_SIZE", QString::number(product->eq_boil_size, 'f', 2)); xmlWriter->writeTextElement("BOIL_TIME", QString::number(product->eq_boil_time, 'f', 0)); xmlWriter->writeEndElement(); // EQUIPMENT xmlWriter->writeStartElement("HOPS"); for (int i = 0; i < product->hops.size(); i++) { xmlWriter->writeStartElement("HOP"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->hops.at(i).h_name); xmlWriter->writeTextElement("ALPHA", QString::number(product->hops.at(i).h_alpha, 'f', 1)); xmlWriter->writeTextElement("AMOUNT", QString::number(product->hops.at(i).h_amount, 'f', 4)); xmlWriter->writeTextElement("USE", hop_use[product->hops.at(i).h_useat]); xmlWriter->writeTextElement("TIME", QString::number(product->hops.at(i).h_time, 'f', 0)); xmlWriter->writeTextElement("TYPE", hop_types[product->hops.at(i).h_type]); xmlWriter->writeTextElement("FORM", hop_forms[product->hops.at(i).h_form]); xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).h_beta, 'f', 1)); xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).h_hsi, 'f', 1)); xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).h_origin); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // HOPS xmlWriter->writeStartElement("FERMENTABLES"); for (int i = 0; i < product->fermentables.size(); i++) { if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { xmlWriter->writeStartElement("FERMENTABLE"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->fermentables.at(i).f_name); xmlWriter->writeTextElement("TYPE", fermentable_type[product->fermentables.at(i).f_type]); xmlWriter->writeTextElement("AMOUNT", QString::number(product->fermentables.at(i).f_amount, 'f', 4)); xmlWriter->writeTextElement("YIELD", QString::number(product->fermentables.at(i).f_yield, 'f', 1)); xmlWriter->writeTextElement("COLOR", QString::number(Utils::ebc_to_srm(product->fermentables.at(i).f_color), 'f', 1)); xmlWriter->writeTextElement("ADD_AFTER_BOIL", product->fermentables.at(i).f_add_after_boil ? "TRUE":"FALSE"); xmlWriter->writeTextElement("ORIGIN", product->fermentables.at(i).f_origin); xmlWriter->writeTextElement("SUPPLIER", product->fermentables.at(i).f_supplier); if (product->fermentables.at(i).f_coarse_fine_diff) xmlWriter->writeTextElement("COARSE_FINE_DIFF", QString::number(product->fermentables.at(i).f_coarse_fine_diff, 'f', 4)); if (product->fermentables.at(i).f_moisture) xmlWriter->writeTextElement("MOISTURE", QString::number(product->fermentables.at(i).f_moisture, 'f', 4)); if (product->fermentables.at(i).f_diastatic_power) xmlWriter->writeTextElement("DIASTATIC_POWER", QString::number(product->fermentables.at(i).f_diastatic_power, 'f', 4)); if (product->fermentables.at(i).f_protein) xmlWriter->writeTextElement("PROTEIN", QString::number(product->fermentables.at(i).f_protein, 'f', 4)); if (product->fermentables.at(i).f_max_in_batch) xmlWriter->writeTextElement("MAX_IN_BATCH", QString::number(product->fermentables.at(i).f_max_in_batch, 'f', 1)); xmlWriter->writeTextElement("RECOMMEND_MASH", product->fermentables.at(i).f_recommend_mash ? "TRUE":"FALSE"); xmlWriter->writeTextElement("GRAINTYPE", fermentable_graintype[product->fermentables.at(i).f_graintype]); xmlWriter->writeEndElement(); } } xmlWriter->writeEndElement(); // FERMENTABLES xmlWriter->writeStartElement("MISCS"); for (int i = 0; i < product->miscs.size(); i++) { xmlWriter->writeStartElement("MISC"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->miscs.at(i).m_name); xmlWriter->writeTextElement("TYPE", misc_type[product->miscs.at(i).m_type]); xmlWriter->writeTextElement("AMOUNT", QString::number(product->miscs.at(i).m_amount, 'f', 5)); xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", product->miscs.at(i).m_amount_is_weight ? "TRUE":"FALSE"); xmlWriter->writeTextElement("USE", misc_use[product->miscs.at(i).m_use_use]); xmlWriter->writeTextElement("TIME", QString::number(product->miscs.at(i).m_time, 'f', 0)); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // MISCS xmlWriter->writeStartElement("YEASTS"); for (int i = 0; i < product->yeasts.size(); i++) { xmlWriter->writeStartElement("YEAST"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->yeasts.at(i).y_name); xmlWriter->writeTextElement("TYPE", yeast_type[product->yeasts.at(i).y_type]); xmlWriter->writeTextElement("FORM", yeast_form[product->yeasts.at(i).y_form]); xmlWriter->writeTextElement("AMOUNT", QString::number(product->yeasts.at(i).y_amount, 'f', 5)); xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", (product->yeasts.at(i).y_form == 1) ? "TRUE":"FALSE"); xmlWriter->writeTextElement("LABORATORY", product->yeasts.at(i).y_laboratory); xmlWriter->writeTextElement("PRODUCT_ID", product->yeasts.at(i).y_product_id); xmlWriter->writeTextElement("MIN_TEMPERATURE", QString::number(product->yeasts.at(i).y_min_temperature, 'f', 1)); xmlWriter->writeTextElement("MAX_TEMPERATURE", QString::number(product->yeasts.at(i).y_max_temperature, 'f', 1)); xmlWriter->writeTextElement("ATTENUATION", QString::number(product->yeasts.at(i).y_attenuation, 'f', 1)); xmlWriter->writeTextElement("ADD_TO_SECONDARY", (product->yeasts.at(i).y_use == 0) ? "FALSE":"TRUE"); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // YEASTS xmlWriter->writeStartElement("WATERS"); if (product->w1_amount > 0) { xmlWriter->writeStartElement("WATER"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->w1_name); xmlWriter->writeTextElement("AMOUNT", QString::number(product->w1_amount, 'f', 2)); xmlWriter->writeTextElement("CALCIUM", QString::number(product->w1_calcium, 'f', 2)); xmlWriter->writeTextElement("MAGNESIUM", QString::number(product->w1_magnesium, 'f', 2)); xmlWriter->writeTextElement("BICARBONATE", QString::number(product->w1_total_alkalinity * 1.22, 'f', 2)); xmlWriter->writeTextElement("SULFATE", QString::number(product->w1_sulfate, 'f', 2)); xmlWriter->writeTextElement("CHLORIDE", QString::number(product->w1_chloride, 'f', 2)); xmlWriter->writeTextElement("SODIUM", QString::number(product->w1_sodium, 'f', 2)); xmlWriter->writeTextElement("PH", QString::number(product->w1_ph, 'f', 2)); xmlWriter->writeTextElement("TOTAL_ALKALINITY", QString::number(product->w1_total_alkalinity, 'f', 2)); xmlWriter->writeEndElement(); if (product->w2_amount > 0) { xmlWriter->writeStartElement("WATER"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->w2_name); xmlWriter->writeTextElement("AMOUNT", QString::number(product->w2_amount, 'f', 2)); xmlWriter->writeTextElement("CALCIUM", QString::number(product->w2_calcium, 'f', 2)); xmlWriter->writeTextElement("MAGNESIUM", QString::number(product->w2_magnesium, 'f', 2)); xmlWriter->writeTextElement("BICARBONATE", QString::number(product->w2_total_alkalinity * 1.22, 'f', 2)); xmlWriter->writeTextElement("SULFATE", QString::number(product->w2_sulfate, 'f', 2)); xmlWriter->writeTextElement("CHLORIDE", QString::number(product->w2_chloride, 'f', 2)); xmlWriter->writeTextElement("SODIUM", QString::number(product->w2_sodium, 'f', 2)); xmlWriter->writeTextElement("PH", QString::number(product->w2_ph, 'f', 2)); xmlWriter->writeTextElement("TOTAL_ALKALINITY", QString::number(product->w2_total_alkalinity, 'f', 2)); xmlWriter->writeEndElement(); } } xmlWriter->writeEndElement(); // WATERS xmlWriter->writeStartElement("MASH"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->mash_name); xmlWriter->writeTextElement("GRAIN_TEMP", "10.0"); xmlWriter->writeTextElement("PH", QString::number(product->sparge_ph, 'f', 2)); xmlWriter->writeTextElement("SPARGE_TEMP", QString::number(product->sparge_temp, 'f', 2)); xmlWriter->writeStartElement("MASH_STEPS"); for (int i = 0; i < product->mashs.size(); i++) { xmlWriter->writeStartElement("MASH_STEP"); xmlWriter->writeTextElement("VERSION", "1"); xmlWriter->writeTextElement("NAME", product->mashs.at(i).step_name); xmlWriter->writeTextElement("TYPE", step_type[product->mashs.at(i).step_type]); if (product->mashs.at(i).step_type == 0) { xmlWriter->writeTextElement("INFUSE_AMOUNT", QString::number(product->mashs.at(i).step_infuse_amount, 'f', 3)); xmlWriter->writeTextElement("INFUSE_TEMP", QString::number(product->mashs.at(i).step_infuse_temp, 'f', 3)); } if (product->mashs.at(i).step_type == 2) { xmlWriter->writeTextElement("DECOCTION_AMT", QString::number(product->mashs.at(i).step_infuse_amount, 'f', 3)); } xmlWriter->writeTextElement("STEP_TEMP", QString::number(product->mashs.at(i).step_temp, 'f', 1)); xmlWriter->writeTextElement("STEP_TIME", QString::number(product->mashs.at(i).step_time, 'f', 1)); xmlWriter->writeTextElement("RAMP_TIME", QString::number(product->mashs.at(i).ramp_time, 'f', 1)); xmlWriter->writeTextElement("END_TEMP", QString::number(product->mashs.at(i).end_temp, 'f', 1)); xmlWriter->writeTextElement("PH", QString::number(product->mash_ph, 'f', 1)); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // MASH_STEPS xmlWriter->writeEndElement(); // MASH xmlWriter->writeEndElement(); // RECIPE xmlWriter->writeEndElement(); // RECIPES xmlWriter->writeEndDocument(); QMessageBox::information(this, tr("Save File"), tr("XML export ready")); file.close(); } void EditProduct::copyProduct() { Product *dup = new Product; dup = product; dup->record = -1; dup->uuid = ""; dup->name.append(" [duplicate]"); dup->code.append("-[dup]"); /* * Clear data of a previous brew if present and roll back stages. * But leave all ingredients and volumes, that's what we want. */ if (dup->stage > PROD_STAGE_WAIT) { dup->stage = dup->inventory_reduced = PROD_STAGE_WAIT; } dup->birth = QDate::currentDate(); dup->brew_date_start = dup->brew_date_end = QDateTime(); dup->brew_mash_ph = dup->brew_mash_sg = dup->brew_mash_efficiency = 0; dup->brew_sparge_ph = 0; dup->brew_preboil_volume = dup->brew_preboil_sg = dup->brew_preboil_ph = dup->brew_preboil_efficiency = 0; dup->brew_aboil_volume = dup->brew_aboil_sg = dup->brew_aboil_ph = dup->brew_aboil_efficiency = 0; dup->brew_cooling_time = 0; dup->brew_fermenter_volume = 0; dup->brew_fermenter_sg = dup->brew_fermenter_ibu = dup->brew_fermenter_color = 0; dup->og = dup->fg = 0; dup->primary_start_temp = dup->primary_max_temp = dup->primary_end_temp = dup->primary_end_sg = 0; dup->primary_end_date = dup->secondary_end_date = QDate(); dup->secondary_temp = dup->secondary_end_sg = dup->tertiary_temp = 0; dup->package_date = QDate(); dup->package_volume = dup->package_abv = dup->package_ph = 0; dup->bottle_amount = dup->bottle_carbonation = dup->bottle_priming_amount = dup->bottle_carbonation_temp = 0; dup->keg_amount = dup->keg_carbonation = dup->keg_priming_amount = dup->keg_carbonation_temp = 0; dup->bottle_priming_water = dup->keg_priming_water = 0; dup->taste_rate = 0; dup->taste_date = QDate(); dup->taste_notes = dup->taste_color = dup->taste_transparency = dup->taste_head = ""; dup->taste_aroma = dup->taste_taste = dup->taste_mouthfeel = dup->taste_aftertaste = ""; dup->starter_viability = 100; dup->yeast_prod_date = QDate(); dup->divide_type = dup->divide_parts = dup->divide_part = 0; dup->divide_size = 0; dup->divide_factor = 1; qDebug() << dup->record << dup->name; if (DB_product::save(dup, this)) { QMessageBox::information(this, tr("Copy Product"), tr("Copy Product export ready.")); } else { QMessageBox::warning(this, tr("Copy Product "), tr("Copy Product error.")); } delete dup; } void EditProduct::copyRecipe() { Recipe *r = new Recipe; r->record = -1; r->name = product->name + QString(" [duplicate]"); r->notes = product->notes; r->locked = false; r->st_name = product->st_name; r->st_letter = product->st_letter; r->st_guide = product->st_guide; r->st_category = product->st_category; r->st_category_number = product->st_category_number; r->st_og_min = product->st_og_min; r->st_og_max = product->st_og_max; r->st_fg_min = product->st_fg_min; r->st_fg_max = product->st_fg_max; r->st_ibu_min = product->st_ibu_min; r->st_ibu_max = product->st_ibu_max; r->st_color_min = product->st_color_min; r->st_color_max = product->st_color_max; r->st_carb_min = product->st_carb_min; r->st_carb_max = product->st_carb_max; r->st_abv_min = product->st_abv_min; r->st_abv_max = product->st_abv_max; r->type = product->type; r->batch_size = product->batch_size; r->boil_size = product->boil_size; r->boil_time = product->boil_time; r->efficiency = product->efficiency; r->est_og = product->est_og; r->est_fg = product->est_fg; r->est_abv = product->est_abv; r->est_carb = 0; r->est_color = product->est_color; r->color_method = product->color_method; r->est_ibu = product->est_ibu; r->ibu_method = product->ibu_method; r->sparge_temp = product->sparge_temp; r->sparge_volume = product->sparge_volume; r->sparge_ph = product->sparge_ph; r->sparge_acid_type = product->sparge_acid_type; r->sparge_acid_perc = product->sparge_acid_perc; r->sparge_acid_amount = 0; r->mash_ph = product->mash_ph; r->mash_name = product->mash_name; r->calc_acid = product->calc_acid; r->w1_name = product->w1_name; r->w1_amount = product->w1_amount; r->w1_calcium = product->w1_calcium; r->w1_sulfate = product->w1_sulfate; r->w1_chloride = product->w1_chloride; r->w1_sodium = product->w1_sodium; r->w1_magnesium = product->w1_magnesium; r->w1_total_alkalinity = product->w1_total_alkalinity; r->w1_ph = product->w1_ph; r->w2_name = product->w2_name; r->w2_amount = product->w2_amount; r->w2_calcium = product->w2_calcium; r->w2_sulfate = product->w2_sulfate; r->w2_chloride = product->w2_chloride; r->w2_sodium = product->w2_sodium; r->w2_magnesium = product->w2_magnesium; r->w2_total_alkalinity = product->w2_total_alkalinity; r->w2_ph = product->w2_ph; r->wg_amount = product->wg_amount; r->wg_calcium = product->wg_calcium; r->wg_sulfate = product->wg_sulfate; r->wg_chloride = product->wg_chloride; r->wg_sodium = product->wg_sodium; r->wg_magnesium = product->wg_magnesium; r->wg_total_alkalinity = product->wg_total_alkalinity; r->wg_ph = product->wg_ph; r->wb_calcium = product->wb_calcium; r->wb_sulfate = product->wb_sulfate; r->wb_chloride = product->wb_chloride; r->wb_sodium = product->wb_sodium; r->wb_magnesium = product->wb_magnesium; r->wb_total_alkalinity = product->wb_total_alkalinity; r->wb_ph = product->wb_ph; r->wa_acid_name = product->wa_acid_name; r->wa_acid_perc = product->wa_acid_perc; r->wa_base_name = product->wa_base_name; r->fermentables = product->fermentables; r->hops = product->hops; r->miscs = product->miscs; r->yeasts = product->yeasts; r->mashs = product->mashs; if (DB_recipe::save(r, this)) { QMessageBox::information(this, tr("Copy Product"), tr("Copy Produuct to Recipe ready.")); } else { QMessageBox::warning(this, tr("Copy Product"), tr("Copy Product to Recipe error.")); } delete r; } void EditProduct::toforumProduct() { } void EditProduct::splitProduct() { } void EditProduct::on_exportButton_clicked() { QDialog* dialog = new QDialog(this); dialog->setWindowTitle(tr("Export choices")); dialog->setObjectName(QString::fromUtf8("Dialog")); dialog->resize(400, 179); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setGeometry(QRect(280, 20, 81, 61)); buttonBox->setOrientation(Qt::Vertical); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); QRadioButton *beerxmlButton = new QRadioButton(dialog); beerxmlButton->setObjectName(QString::fromUtf8("beerxmlButton")); beerxmlButton->setGeometry(QRect(50, 20, 171, 21)); beerxmlButton->setText(tr("Export to beerXML")); QRadioButton *copy_productButton = new QRadioButton(dialog); copy_productButton->setObjectName(QString::fromUtf8("copy_productButton")); copy_productButton->setGeometry(QRect(50, 50, 171, 21)); copy_productButton->setText(tr("Copy to product")); /* QRadioButton *splitButton = new QRadioButton(dialog); splitButton->setObjectName(QString::fromUtf8("splitButton")); splitButton->setGeometry(QRect(50, 110, 171, 21)); splitButton->setText(tr("Split this batch")); */ QRadioButton *copy_recipeButton = new QRadioButton(dialog); 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); toforumButton->setObjectName(QString::fromUtf8("toforumButton")); toforumButton->setGeometry(QRect(50, 140, 171, 21)); toforumButton->setText(tr("Export to forum")); */ QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); dialog->setModal(true); dialog->exec(); if (dialog->result() == QDialog::Accepted) { if (beerxmlButton->isChecked()) exportBeerXML(); if (copy_productButton->isChecked()) copyProduct(); if (copy_recipeButton->isChecked()) copyRecipe(); } disconnect(buttonBox, nullptr, nullptr, nullptr); } void EditProduct::on_printButton_clicked() { QDialog* dialog = new QDialog(this); dialog->setWindowTitle(tr("Printer report")); dialog->setObjectName(QString::fromUtf8("Dialog")); dialog->resize(400, 101); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setGeometry(QRect(280, 20, 81, 61)); buttonBox->setOrientation(Qt::Vertical); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); QRadioButton *recipeButton = new QRadioButton(dialog); recipeButton->setObjectName(QString::fromUtf8("recipeButton")); recipeButton->setGeometry(QRect(50, 20, 171, 21)); recipeButton->setText(tr("Print recipe")); QRadioButton *checklistButton = new QRadioButton(dialog); checklistButton->setObjectName(QString::fromUtf8("checklistButton")); checklistButton->setGeometry(QRect(50, 50, 171, 21)); checklistButton->setText(tr("Print checklist")); QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); dialog->setModal(true); dialog->exec(); if (dialog->result() == QDialog::Accepted) { if (checklistButton->isChecked()) PrinterDialog(PR_CHECKLIST, -1, this); if (recipeButton->isChecked()) PrinterDialog(PR_PRODUCT, -1, this); } disconnect(buttonBox, nullptr, nullptr, nullptr); }