296 } |
309 } |
297 } else if (p_job == PR_RECIPE) { |
310 } else if (p_job == PR_RECIPE) { |
298 |
311 |
299 printHeader(&painter); |
312 printHeader(&painter); |
300 y = 120; |
313 y = 120; |
301 |
314 /* Fermentables supplies header */ |
|
315 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
316 painter.setPen(Qt::black); |
|
317 painter.fillRect( 0, y, 735, 20, c_header); |
|
318 painter.drawText( 0, y+4, 735, 20, Qt::AlignCenter, tr("Recipe overview")); |
|
319 y += 20; |
|
320 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
321 painter.fillRect( 0, y, 300, 20, c_line1); |
|
322 painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Brew type")); |
|
323 painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, recipe_types[recipe->type]); |
|
324 painter.fillRect(435, y, 300, 20, c_line1); |
|
325 painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Efficiency")); |
|
326 painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 %").arg(recipe->efficiency, 1, 'f', 1)); |
|
327 y += 20; |
|
328 painter.fillRect( 0, y, 300, 20, c_line1); |
|
329 painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Boil time")); |
|
330 painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 minutes.").arg(recipe->boil_time, 1, 'f', 0)); |
|
331 painter.fillRect(435, y, 300, 20, c_line1); |
|
332 painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Batch size")); |
|
333 painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L.").arg(recipe->batch_size, 1, 'f', 1)); |
|
334 y += 20; |
|
335 painter.fillRect( 0, y, 300, 20, c_line1); |
|
336 painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Start SG")); |
|
337 painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_og, 1, 'f', 3)); |
|
338 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_og_min, 1, 'f', 3).arg(recipe->st_og_max, 1, 'f', 3)); |
|
339 painter.fillRect(435, y, 300, 20, c_line1); |
|
340 painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("End SG")); |
|
341 painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_fg, 1, 'f', 3)); |
|
342 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_fg_min, 1, 'f', 3).arg(recipe->st_fg_max, 1, 'f', 3)); |
|
343 y += 20; |
|
344 painter.fillRect( 0, y, 300, 20, c_line1); |
|
345 painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Estimated Alcohol")); |
|
346 painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1%").arg(recipe->est_abv, 1, 'f', 1)); |
|
347 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_abv_min, 1, 'f', 1).arg(recipe->st_abv_max, 1, 'f', 1)); |
|
348 painter.fillRect(435, y, 300, 20, c_line1); |
|
349 painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Estimated CO2 vol")); |
|
350 painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_carb, 1, 'f', 1)); |
|
351 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_carb_min, 1, 'f', 1).arg(recipe->st_carb_max, 1, 'f', 1)); |
|
352 y += 20; |
|
353 painter.fillRect( 0, y, 120, 20, c_line1); |
|
354 painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Color (") + color_method[recipe->color_method] + ")"); |
|
355 painter.fillRect(120, y, 180, 20, Utils::ebc_to_color(recipe->est_color)); |
|
356 if (recipe->est_color > 30) |
|
357 painter.setPen(Qt::white); |
|
358 painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1 EBC").arg(recipe->est_color, 1, 'f', 0)); |
|
359 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_color_min, 1, 'f', 0).arg(recipe->st_color_max, 1, 'f', 0)); |
|
360 painter.setPen(Qt::black); |
|
361 painter.fillRect(435, y, 300, 20, c_line1); |
|
362 painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("IBU (") + ibu_method[recipe->ibu_method] + ")"); |
|
363 painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_ibu, 1, 'f', 1)); |
|
364 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_ibu_min, 1, 'f', 0).arg(recipe->st_ibu_max, 1, 'f', 0)); |
|
365 y += 40; |
|
366 |
|
367 /* Fermentables */ |
|
368 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
369 painter.setPen(Qt::black); |
|
370 painter.fillRect( 0, y, 735, 20, c_header); |
|
371 painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, tr("Fermentable")); |
|
372 painter.drawText(265, y+4, 70, 20, Qt::AlignRight, tr("Percent")); |
|
373 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("Yield")); |
|
374 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
|
375 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
|
376 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
|
377 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
|
378 y += 20; |
|
379 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
380 double cost_fermentables = 0; |
|
381 QString soort, amount, use; |
|
382 for (int i = 0; i < recipe->fermentables.size(); i++) { |
|
383 double cost = recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_cost; |
|
384 cost_fermentables += cost; |
|
385 |
|
386 if (recipe->fermentables.at(i).f_type == 0) |
|
387 soort = fermentable_graintypes[recipe->fermentables.at(i).f_graintype]; |
|
388 else |
|
389 soort = fermentable_types[recipe->fermentables.at(i).f_type]; |
|
390 |
|
391 if (recipe->fermentables.at(i).f_amount > 100) |
|
392 amount = QString("%1 kg").arg(recipe->fermentables.at(i).f_amount, 1, 'f', 1); |
|
393 else if (recipe->fermentables.at(i).f_amount > 10) |
|
394 amount = QString("%1 kg").arg(recipe->fermentables.at(i).f_amount, 1, 'f', 2); |
|
395 else |
|
396 amount = QString("%1 gr").arg(recipe->fermentables.at(i).f_amount * 1000, 1, 'f', 0); |
|
397 |
|
398 painter.fillRect( 0, y, 735, 20, f_line); |
|
399 |
|
400 painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->fermentables.at(i).f_name + |
|
401 QString(", %1 EBC (").arg(recipe->fermentables.at(i).f_color, 1, 'f', 0) + |
|
402 recipe->fermentables.at(i).f_supplier + ")"); |
|
403 painter.drawText(265, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->fermentables.at(i).f_percentage, 1, 'f', 1)); |
|
404 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->fermentables.at(i).f_yield, 1, 'f', 1)); |
|
405 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, soort); |
|
406 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, fermentable_added[recipe->fermentables.at(i).f_added]); |
|
407 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
|
408 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
|
409 y += 20; |
|
410 } |
|
411 painter.fillRect(670, y, 60, 20, c_line1); |
|
412 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_fermentables, 1, 'f', 3)); |
|
413 y += 40; |
|
414 |
|
415 /* Hops */ |
|
416 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
417 painter.fillRect( 0, y, 735, 20, c_header); |
|
418 painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, tr("Hop")); |
|
419 painter.drawText(265, y+4, 70, 20, Qt::AlignRight, tr("Alpha")); |
|
420 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("IBU")); |
|
421 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
|
422 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
|
423 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
|
424 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
|
425 y += 20; |
|
426 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
427 double cost_hops = 0; |
|
428 for (int i = 0; i < recipe->hops.size(); i++) { |
|
429 |
|
430 double cost = recipe->hops.at(i).h_amount * recipe->hops.at(i).h_cost; |
|
431 cost_hops += cost; |
|
432 double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, |
|
433 recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, |
|
434 recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0); |
|
435 |
|
436 if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) // Boil or Whirlpool |
|
437 use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 min").arg(recipe->hops.at(i).h_time); |
|
438 else if (recipe->hops.at(i).h_useat == 5) // Dryhop |
|
439 use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 days").arg(recipe->hops.at(i).h_time / 1440); |
|
440 else |
|
441 use = hop_useat[recipe->hops.at(i).h_useat]; |
|
442 |
|
443 if (recipe->hops.at(i).h_amount > 1) |
|
444 amount = QString("%1 kg").arg(recipe->hops.at(i).h_amount, 1, 'f', 3); |
|
445 else |
|
446 amount = QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000, 1, 'f', 1); |
|
447 |
|
448 painter.fillRect( 0, y, 735, 20, h_line); |
|
449 painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")"); |
|
450 painter.drawText(265, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).h_alpha, 1, 'f', 1)); |
|
451 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); |
|
452 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).h_form]); |
|
453 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, use); |
|
454 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
|
455 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
|
456 y += 20; |
|
457 } |
|
458 painter.fillRect(670, y, 60, 20, c_line1); |
|
459 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_hops, 1, 'f', 3)); |
|
460 y += 40; |
|
461 |
|
462 /* Yeasts */ |
|
463 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
464 painter.fillRect( 0, y, 735, 20, c_header); |
|
465 painter.drawText( 0, y+4, 335, 20, Qt::AlignLeft, tr("Yeast")); |
|
466 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("Attn")); |
|
467 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
|
468 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
|
469 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
|
470 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
|
471 y += 20; |
|
472 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
473 double cost_yeasts = 0; |
|
474 for (int i = 0; i < recipe->yeasts.size(); i++) { |
|
475 double cost = recipe->yeasts.at(i).y_amount * recipe->yeasts.at(i).y_cost; |
|
476 cost_yeasts += cost; |
|
477 |
|
478 if (recipe->yeasts.at(i).y_form == 0) |
|
479 amount = QString("%1 pack").arg(recipe->yeasts.at(i).y_amount, 1, 'f', 0); |
|
480 else if (recipe->yeasts.at(i).y_form == 1 || recipe->yeasts.at(i).y_form == 6) |
|
481 amount = QString("%1 gr").arg(recipe->yeasts.at(i).y_amount * 1000.0, 1, 'f', 1); |
|
482 else |
|
483 amount = QString("%1 ml").arg(recipe->yeasts.at(i).y_amount * 1000.0, 1, 'f', 1); |
|
484 |
|
485 painter.fillRect( 0, y, 735, 20, y_line); |
|
486 painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->yeasts.at(i).y_laboratory + " " + |
|
487 recipe->yeasts.at(i).y_product_id + " (" + |
|
488 recipe->yeasts.at(i).y_name + ")"); |
|
489 painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->yeasts.at(i).y_attenuation, 1, 'f', 1)); |
|
490 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, yeast_forms[recipe->yeasts.at(i).y_form]); |
|
491 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, yeast_use[recipe->yeasts.at(i).y_use]); |
|
492 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
|
493 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
|
494 y += 20; |
|
495 } |
|
496 painter.fillRect(670, y, 60, 20, c_line1); |
|
497 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_yeasts, 1, 'f', 3)); |
|
498 y += 40; |
|
499 |
|
500 /* Miscs */ |
|
501 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
502 painter.fillRect( 0, y, 735, 20, c_header); |
|
503 painter.drawText( 0, y+4, 410, 20, Qt::AlignLeft, tr("Misc ingredient")); |
|
504 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
|
505 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
|
506 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
|
507 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
|
508 y += 20; |
|
509 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
510 double cost_miscs = 0; |
|
511 for (int i = 0; i < recipe->miscs.size(); i++) { |
|
512 double cost = recipe->miscs.at(i).m_amount * recipe->miscs.at(i).m_cost; |
|
513 cost_miscs += cost; |
|
514 |
|
515 if (recipe->miscs.at(i).m_use_use == 2) |
|
516 use = misc_uses[recipe->miscs.at(i).m_use_use] + QString(" %1 min").arg(recipe->miscs.at(i).m_time); |
|
517 else |
|
518 use = misc_uses[recipe->miscs.at(i).m_use_use]; |
|
519 |
|
520 if (recipe->miscs.at(i).m_type == 4) // Water agent |
|
521 painter.fillRect( 0, y, 735, 20, mw_line); |
|
522 else if (recipe->miscs.at(i).m_type == 3) // Fining |
|
523 painter.fillRect( 0, y, 735, 20, mf_line); |
|
524 else if (recipe->miscs.at(i).m_type < 3 || recipe->miscs.at(i).m_type == 5) // Spice, Herb, Flavour, Yeast nutrient |
|
525 painter.fillRect( 0, y, 735, 20, ms_line); |
|
526 else |
|
527 painter.fillRect( 0, y, 735, 20, mo_line); |
|
528 painter.drawText( 0, y+4, 410, 20, Qt::AlignLeft, recipe->miscs.at(i).m_name); |
|
529 painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, misc_types[recipe->miscs.at(i).m_type]); |
|
530 painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, use); |
|
531 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, |
|
532 QString("%1 %2").arg(recipe->miscs.at(i).m_amount * 1000.0, 1, 'f', 1).arg(recipe->miscs.at(i).m_amount_is_weight ? "gr":"ml")); |
|
533 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
|
534 y += 20; |
|
535 } |
|
536 painter.fillRect(670, y, 60, 20, c_line1); |
|
537 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_miscs, 1, 'f', 3)); |
|
538 y += 40; |
|
539 |
|
540 /* Mash */ |
|
541 painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
|
542 painter.fillRect( 0, y, 735, 20, c_header); |
|
543 painter.drawText( 0, y+4, 160, 20, Qt::AlignLeft, tr("Mash step")); |
|
544 painter.drawText(165, y+4, 90, 20, Qt::AlignLeft, tr("Step type")); |
|
545 painter.drawText(260, y+4, 60, 20, Qt::AlignRight, tr("Start °C")); |
|
546 painter.drawText(325, y+4, 60, 20, Qt::AlignRight, tr("End °C")); |
|
547 painter.drawText(390, y+4, 60, 20, Qt::AlignRight, tr("Time")); |
|
548 painter.drawText(455, y+4, 60, 20, Qt::AlignRight, tr("Ramp")); |
|
549 painter.drawText(520, y+4, 60, 20, Qt::AlignRight, tr("L/kg")); |
|
550 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, tr("Inf/dec L.")); |
|
551 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, tr("Inf/dec °C")); |
|
552 y += 20; |
|
553 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
|
554 for (int i = 0; i < recipe->mashs.size(); i++) { |
|
555 painter.fillRect( 0, y, 735, 20, m_line); |
|
556 painter.drawText( 0, y+4, 160, 20, Qt::AlignLeft, recipe->mashs.at(i).step_name); |
|
557 painter.drawText(165, y+4, 90, 20, Qt::AlignLeft, step_types[recipe->mashs.at(i).step_type]); |
|
558 painter.drawText(260, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_temp, 1, 'f', 1)); |
|
559 painter.drawText(325, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).end_temp, 1, 'f', 1)); |
|
560 painter.drawText(390, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_time, 1, 'f', 0)); |
|
561 painter.drawText(455, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).ramp_time, 1, 'f', 0)); |
|
562 painter.drawText(520, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_wg_ratio, 1, 'f', 2)); |
|
563 if (recipe->mashs.at(i).step_type != 1) { |
|
564 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_infuse_amount, 1, 'f', 1)); |
|
565 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_infuse_temp, 1, 'f', 1)); |
|
566 } |
|
567 y += 20; |
|
568 } |
302 } |
569 } |
303 |
570 |
304 |
571 |
305 painter.end(); |
572 painter.end(); |
306 } |
573 } |