src/EditRecipeExport.cpp

changeset 257
cfba041bdaee
parent 253
d130385c1b0d
child 260
42b88d85fefc
equal deleted inserted replaced
256:c136bd15b084 257:cfba041bdaee
43 if (fileName == 0) { 43 if (fileName == 0) {
44 QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); 44 QMessageBox::warning(this, tr("Save File"), tr("No XML file selected."));
45 return; 45 return;
46 } 46 }
47 47
48 qInfo() << "Recipe to beerXML" << fileName;
48 QFile file(fileName); 49 QFile file(fileName);
49 file.open(QIODevice::WriteOnly); 50 file.open(QIODevice::WriteOnly);
50 51
51 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); 52 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file);
52 xmlWriter->writeStartDocument(); 53 xmlWriter->writeStartDocument();
265 Recipe *dup = new Recipe; 266 Recipe *dup = new Recipe;
266 267
267 dup = recipe; 268 dup = recipe;
268 dup->record = -1; 269 dup->record = -1;
269 dup->uuid = ""; 270 dup->uuid = "";
271 dup->name.append(" [duplicate]");
270 qDebug() << dup->record << dup->name; 272 qDebug() << dup->record << dup->name;
271 if (DB_recipe::save(dup, this)) { 273 if (DB_recipe::save(dup, this)) {
272 QMessageBox::information(this, tr("Copy Recipe"), tr("Copy Recipe export ready.")); 274 QMessageBox::information(this, tr("Copy Recipe"), tr("Copy Recipe export ready."));
273 } else { 275 } else {
274 QMessageBox::warning(this, tr("Copy Recipe"), tr("Copy Recipe error.")); 276 QMessageBox::warning(this, tr("Copy Recipe"), tr("Copy Recipe error."));
363 p->taste_rate = 0; 365 p->taste_rate = 0;
364 p->taste_date = QDate(); 366 p->taste_date = QDate();
365 p->taste_notes = p->taste_color = p->taste_transparency = p->taste_head = ""; 367 p->taste_notes = p->taste_color = p->taste_transparency = p->taste_head = "";
366 p->taste_aroma = p->taste_taste = p->taste_mouthfeel = p->taste_aftertaste = ""; 368 p->taste_aroma = p->taste_taste = p->taste_mouthfeel = p->taste_aftertaste = "";
367 369
368 p->sparge_temp = 80; 370 p->sparge_temp = recipe->sparge_temp;
369 p->sparge_ph = 5.4; 371 p->sparge_ph = recipe->sparge_ph;
370 p->sparge_volume = 8; 372 p->sparge_volume = recipe->sparge_volume;
371 p->sparge_source = 0; 373 p->sparge_source = recipe->sparge_source;
372 p->sparge_acid_type = 0; 374 p->sparge_acid_type = recipe->sparge_acid_type;
373 p->sparge_acid_perc = 80; 375 p->sparge_acid_perc = recipe->sparge_acid_perc;
374 p->sparge_acid_amount = 0; 376 p->sparge_acid_amount = recipe->sparge_acid_amount;
375 p->mash_ph = 5.4; 377 p->mash_ph = recipe->mash_ph;
376 p->mash_name = ""; 378 p->mash_name = recipe->mash_name;
377 379
378 p->calc_acid = true; 380 p->calc_acid = recipe->calc_acid;
379 p->w1_name = recipe->w1_name; 381 p->w1_name = recipe->w1_name;
380 p->w1_amount = recipe->w1_amount; 382 p->w1_amount = recipe->w1_amount;
381 p->w1_calcium = recipe->w1_calcium; 383 p->w1_calcium = recipe->w1_calcium;
382 p->w1_sulfate = recipe->w1_sulfate; 384 p->w1_sulfate = recipe->w1_sulfate;
383 p->w1_chloride = recipe->w1_chloride; 385 p->w1_chloride = recipe->w1_chloride;
435 } 437 }
436 delete p; 438 delete p;
437 } 439 }
438 440
439 441
440 void EditRecipe::toforumRecipe() { } 442 void EditRecipe::toforumRecipe()
443 {
444 const QStringList recipetypes({ "Extract", "Partial Mash", "All Grain" });
445 const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
446 const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
447 const QStringList fermentable_added({ "Maischen", "Koken", "Hoofd/nagisting", "Lageren", "Bottelen", "Fusten" });
448 const QStringList hop_forms({ "Pellet", "Plug", "Bloemen", "Verse hop", "Cryo" });
449 const QStringList hop_use({ "Maischen", "First wort", "Koken", "Vlamuit", "Whirlpool", "Drooghop" });
450 const QStringList misc_type({ "Spice", "Herb", "Smaakstof", "Klaren", "Brouwzout", "Gist voeding", "Overig" });
451 const QStringList misc_use({ "Starter", "Maischen", "Koken", "Hoofdgisting", "Nagisting", "Bottelen" });
452 const QStringList yeast_form({ "Vloeibaar", "Droog", "Schuine buis", "Opkweek", "Ingevroren", "Flesbodem", "Gedroogd" });
453 const QStringList yeast_use({ "Hoofdgisting", "Nagisting", "Lageren", "Bottelen", "Fusten" });
454 const QStringList step_type({ "Infusie", "Verwarmen", "Decoctie" });
455
456 QString memo = QString("[u][b]BMSapp v");
457 memo.append(VERSIONSTRING); // For some stupid reason this must be on it's own.
458 memo.append(" - Datum export: " + QDate::currentDate().toString("dd-MMM-yyyy") + "[/b][/u]\n\n\n");
459 memo.append("[u][b]Basis[/b][/u]\n[tabular]\n");
460 memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
461 memo.append("[row][data]Bier naam[/data][data]" + recipe->name + "[/data][/row]\n");
462 memo.append("[row][data]Bier stijl[/data][data]" + recipe->st_name + "[/data][/row]\n");
463 memo.append("[row][data]Recept type[/data][data]" + recipetypes[recipe->type] + "[/data][/row]\n");
464 memo.append("[row][data]Batch grootte[/data][data]" + QString::number(recipe->batch_size, 'f', 1) + " L[/data][/row]\n");
465 memo.append("[row][data]Kooktijd[/data][data]" + QString::number(recipe->boil_time, 'f', 0) + " minuten[/data][/row]\n");
466 memo.append("[row][data]Brouwzaal rendement[/data][data]" + QString::number(recipe->efficiency, 'f', 1) + "%[/data][/row]\n");
467 memo.append("[row][data]Geschatte begin densiteit[/data][data]" + QString::number(recipe->est_og, 'f', 3) + " SG[/data][/row]\n");
468 memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(recipe->est_fg, 'f', 3) + " SG[/data][/row]\n");
469 memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(recipe->est_abv, 'f', 1) + "%[/data][/row]\n");
470 memo.append("[row][data]Kleur (" + color_method[recipe->color_method] + ")[/data][data]" + QString::number(recipe->est_color, 'f', 0) + " EBC[/data][/row]\n");
471 memo.append("[row][data]Bitterheid (" + ibu_method[recipe->ibu_method] + ")[/data][data]" + QString::number(recipe->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
472 memo.append("[/tabular]\n\n");
473
474 memo.append("[u][b]Vergistbare ingrediënten[/b][/u]\n");
475 memo.append("[tabular]\n");
476 memo.append("[head]Mout, granen en suikers[/head][head]EBC[/head][head]Gewicht kg[/head][head]%[/head][head]Gebruik tijdens[/head]\n");
477 for (int i = 0; i < recipe->fermentables.size(); i++) {
478 memo.append("[row][data]" + recipe->fermentables.at(i).f_name + " (" + recipe->fermentables.at(i).f_supplier + ")[/data]");
479 memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_color) + "[/data]");
480 memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_amount, 'f', 3) + "[/data]");
481 memo.append("[data]" + QString::number(recipe->fermentables.at(i).f_percentage, 'f', 1) + "[/data]");
482 memo.append("[data]" + fermentable_added[recipe->fermentables.at(i).f_added] + "[/data][/row]\n");
483 }
484 memo.append("[/tabular]\n\n");
485
486 memo.append("[u][b]Hop[/b][/u]\n");
487 memo.append("[tabular]\n");
488 memo.append("[head]Hop[/head][head]Vorm[/head][head]Alpha[/head][head]IBU[/head][head]Gram[/head][head]Toevoegen moment[/head]\n");
489 for (int i = 0; i < recipe->hops.size(); i++) {
490 double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size,
491 recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method,
492 0, recipe->hops.at(i).h_time, 0, recipe->boil_time);
493 memo.append("[row][data]" + recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")[/data]");
494 memo.append("[data]" + hop_forms[recipe->hops.at(i).h_form] + "[/data]");
495 memo.append("[data]" + QString::number(recipe->hops.at(i).h_alpha, 'f', 1) + "[/data]");
496 memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]");
497 memo.append("[data]" + QString::number(recipe->hops.at(i).h_amount * 1000, 'f', 2) + "[/data]");
498 if (recipe->hops.at(i).h_useat == HOP_USEAT_BOIL || recipe->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL)
499 memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time) + " minuten[/data][/row]\n");
500 else if (recipe->hops.at(i).h_useat == HOP_USEAT_DRY_HOP)
501 memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time / 1440) + " dagen[/data][/row]\n");
502 else
503 memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + "[/data][/row]\n");
504 }
505 memo.append("[/tabular]\n\n");
506
507 memo.append("[u][b]Diversen[/b][/u]\n");
508 memo.append("[tabular]\n");
509 memo.append("[head]Specerij, kruid, brouwzout[/head][head]Type grondstof[/head][head]Gebruik tijdens[/head][head]Hoeveel[/head]\n");
510 for (int i = 0; i < recipe->miscs.size(); i++) {
511 memo.append("[row][data]" + recipe->miscs.at(i).m_name + "[/data]");
512 memo.append("[data]" + misc_type[recipe->miscs.at(i).m_type] + "[/data]");
513 if (recipe->miscs.at(i).m_use_use == MISC_USES_BOIL)
514 memo.append("[data]" + misc_use[recipe->miscs.at(i).m_use_use] + " " + QString::number(recipe->miscs.at(i).m_time) + " min[/data]");
515 else
516 memo.append("[data]" + misc_use[recipe->miscs.at(i).m_use_use] + "[/data]");
517 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");
518 }
519 memo.append("[/tabular]\n\n");
520
521 memo.append("[u][b]Gist[/b][/u]\n");
522 memo.append("[tabular]\n");
523 memo.append("[head]Gistlab en code[/head][head]Omschrijving[/head][head]Gebruik[/head][head]Vorm[/head][head]Hoeveel[/head]\n");
524 for (int i = 0; i < recipe->yeasts.size(); i++) {
525 memo.append("[row][data]" + recipe->yeasts.at(i).y_laboratory + " " + recipe->yeasts.at(i).y_product_id + "[/data]");
526 memo.append("[data]" + recipe->yeasts.at(i).y_name + "[/data]");
527 memo.append("[data]" + yeast_use[recipe->yeasts.at(i).y_use] + "[/data]");
528 memo.append("[data]" + yeast_form[recipe->yeasts.at(i).y_form] + "[/data]");
529 if (recipe->yeasts.at(i).y_form == YEAST_FORMS_LIQUID)
530 memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount, 'f', 0) + " pak[/data][/row]\n");
531 else if (recipe->yeasts.at(i).y_form == YEAST_FORMS_DRY || recipe->yeasts.at(i).y_form == YEAST_FORMS_DRIED)
532 memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount * 1000, 'f', 1) + " gr[/data][/row]\n");
533 else
534 memo.append("[data]" + QString::number(recipe->yeasts.at(i).y_amount * 1000, 'f', 0) + " ml[/data][/row]\n");
535 }
536 memo.append("[/tabular]\n\n");
537
538 memo.append("[u][b]Maischen[/b][/u]\n");
539 memo.append("[tabular]\n");
540 memo.append("[head]Maisch stap[/head][head]Stap type[/head][head]Temperatuur[/head][head]Rust tijd[/head][head]Opwarm tijd[/head]\n");
541 for (int i = 0; i < recipe->mashs.size(); i++) {
542 memo.append("[row][data]" + recipe->mashs.at(i).step_name + "[/data]");
543 if (recipe->mashs.at(i).step_type != 1)
544 memo.append("[data]" + step_type[recipe->mashs.at(i).step_type]+" "+QString::number(recipe->mashs.at(i).step_infuse_amount, 'f', 1) + " L[/data]");
545 else
546 memo.append("[data]" + step_type[recipe->mashs.at(i).step_type] + "[/data]");
547 memo.append("[data]" + QString::number(recipe->mashs.at(i).step_temp, 'f', 1) + " °C[/data]");
548 memo.append("[data]" + QString::number(recipe->mashs.at(i).step_time, 'f', 0) + " min[/data]");
549 memo.append("[data]" + QString::number(recipe->mashs.at(i).ramp_time, 'f', 0) + " min[/data][/row]\n");
550 }
551 memo.append("[/tabular]\n\n");
552
553 memo.append("[u][b]Brouwwater[/b][/u]\n");
554 memo.append("[tabular]\n");
555 memo.append("[head]Omschrijving[/head][head]Waarde[/head]\n");
556 if (recipe->w2_name != "" && recipe->w2_amount > 0) {
557 memo.append("[row][data]Maischwater 1[/data][data]" + recipe->w1_name + " " + QString::number(recipe->w1_amount, 'f', 1) + " Liter[/data][/row]\n");
558 memo.append("[row][data]Maischwater 2[/data][data]" + recipe->w2_name + " " + QString::number(recipe->w2_amount, 'f', 1) + " Liter[/data][/row]\n");
559 } else {
560 memo.append("[row][data]Maischwater[/data][data]" + recipe->w1_name + " " + QString::number(recipe->w1_amount, 'f', 1) + " Liter[/data][/row]\n");
561 }
562 memo.append("[row][data]Maischwater aanzuren tot[/data][data]" + QString::number(recipe->mash_ph, 'f', 1) + " pH[/data][/row]\n");
563 memo.append("[row][data]Spoelwater geschat[/data][data]" + QString::number(recipe->sparge_volume, 'f', 1) + " Liter[/data][/row]\n");
564 memo.append("[row][data]Spoelwater temperatuur[/data][data]" + QString::number(recipe->sparge_temp, 'f', 1) + " °C[/data][/row]\n");
565 memo.append("[row][data]Spoelwater aanzuren tot[/data][data]" + QString::number(recipe->sparge_ph, 'f', 1) + " pH[/data][/row]\n");
566 memo.append("[/tabular]\n\n");
567
568 memo.append("[u][b]Waterprofiel behandeld water[/b][/u]\n");
569 memo.append("[tabular]\n");
570 memo.append("[head]Ca[/head][head]Mg[/head][head]Na[/head][head]HCO3[/head][head]Cl[/head][head]SO4[/head]\n");
571 memo.append("[row][data]" + QString::number(recipe->wb_calcium, 'f', 1) + "[/data]");
572 memo.append("[data]" + QString::number(recipe->wb_magnesium, 'f', 1) + "[/data]");
573 memo.append("[data]" + QString::number(recipe->wb_sodium, 'f', 1) + "[/data]");
574 memo.append("[data]" + QString::number(recipe->wb_total_alkalinity * 61 / 50, 'f', 1) + "[/data]");
575 memo.append("[data]" + QString::number(recipe->wb_chloride, 'f', 1) + "[/data]");
576 memo.append("[data]" + QString::number(recipe->wb_sulfate, 'f', 1) + "[/data][/row]\n");
577 memo.append("[/tabular]\n\n");
578
579 qDebug().noquote() << memo;
580 QGuiApplication::clipboard()->setText(memo, QClipboard::Clipboard);
581 QGuiApplication::clipboard()->setText(memo, QClipboard::Selection);
582
583 QMessageBox::information(this, tr("Export to forum"), tr("The recipe and all data are copied to the clipboard.\n"
584 "You can \"paste\" this data in the forum screen in your web browser."));
585 }
441 586
442 void EditRecipe::on_exportButton_clicked() 587 void EditRecipe::on_exportButton_clicked()
443 { 588 {
444 QDialog* dialog = new QDialog(this); 589 QDialog* dialog = new QDialog(this);
445 dialog->setWindowTitle(tr("Export choices")); 590 dialog->setWindowTitle(tr("Export choices"));
481 exportBeerXML(); 626 exportBeerXML();
482 if (copy_recipeButton->isChecked()) 627 if (copy_recipeButton->isChecked())
483 copyRecipe(); 628 copyRecipe();
484 if (copy_productButton->isChecked()) 629 if (copy_productButton->isChecked())
485 copyProduct(); 630 copyProduct();
631 if (toforumButton->isChecked())
632 toforumRecipe();
486 } 633 }
487 634
488 disconnect(buttonBox, nullptr, nullptr, nullptr); 635 disconnect(buttonBox, nullptr, nullptr, nullptr);
489 } 636 }
490 637

mercurial