src/PrinterDialog.cpp

changeset 282
d1d208a857b0
parent 280
efc213beb605
child 283
242a68fa7186
equal deleted inserted replaced
281:af3dac6ff6c3 282:d1d208a857b0
433 y += 20; 433 y += 20;
434 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); 434 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
435 double cost_hops = 0; 435 double cost_hops = 0;
436 for (int i = 0; i < recipe->hops.size(); i++) { 436 for (int i = 0; i < recipe->hops.size(); i++) {
437 437
438 double cost = recipe->hops.at(i).h_amount * recipe->hops.at(i).h_cost; 438 double cost = recipe->hops.at(i).amount * recipe->hops.at(i).cost;
439 cost_hops += cost; 439 cost_hops += cost;
440 double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, 440 double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size,
441 recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, 441 recipe->hops.at(i).amount, recipe->hops.at(i).time, recipe->hops.at(i).alpha,
442 recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0, recipe->boil_time); 442 recipe->ibu_method, 0, recipe->hops.at(i).time, 0, recipe->boil_time);
443 443
444 if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) // Boil or Whirlpool 444 if (recipe->hops.at(i).useat == 2 || recipe->hops.at(i).useat == 4) // Boil or Whirlpool
445 use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 min").arg(recipe->hops.at(i).h_time); 445 use = hop_useat[recipe->hops.at(i).useat] + QString(" %1 min").arg(recipe->hops.at(i).time);
446 else if (recipe->hops.at(i).h_useat == 5) // Dryhop 446 else if (recipe->hops.at(i).useat == 5) // Dryhop
447 use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 days").arg(recipe->hops.at(i).h_time / 1440); 447 use = hop_useat[recipe->hops.at(i).useat] + QString(" %1 days").arg(recipe->hops.at(i).time / 1440);
448 else 448 else
449 use = hop_useat[recipe->hops.at(i).h_useat]; 449 use = hop_useat[recipe->hops.at(i).useat];
450 450
451 if (recipe->hops.at(i).h_amount > 1) 451 if (recipe->hops.at(i).amount > 1)
452 amount = QString("%1 kg").arg(recipe->hops.at(i).h_amount, 1, 'f', 3); 452 amount = QString("%1 kg").arg(recipe->hops.at(i).amount, 1, 'f', 3);
453 else 453 else
454 amount = QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000, 1, 'f', 1); 454 amount = QString("%1 gr").arg(recipe->hops.at(i).amount * 1000, 1, 'f', 1);
455 455
456 painter.fillRect( 20, y, 715, 20, h_line); 456 painter.fillRect( 20, y, 715, 20, h_line);
457 painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")"); 457 painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).name + " (" + recipe->hops.at(i).origin + ")");
458 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).h_alpha, 1, 'f', 1)); 458 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).alpha, 1, 'f', 1));
459 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); 459 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1));
460 painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).h_form]); 460 painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).form]);
461 painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use); 461 painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use);
462 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); 462 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount);
463 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); 463 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3));
464 y += 20; 464 y += 20;
465 } 465 }
833 y += 20; 833 y += 20;
834 painter.setFont(QFont("Helvetica", 9, QFont::Normal)); 834 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
835 double cost_hops = 0; 835 double cost_hops = 0;
836 for (int i = 0; i < product->hops.size(); i++) { 836 for (int i = 0; i < product->hops.size(); i++) {
837 837
838 double cost = product->hops.at(i).h_amount * product->hops.at(i).h_cost; 838 double cost = product->hops.at(i).amount * product->hops.at(i).cost;
839 cost_hops += cost; 839 cost_hops += cost;
840 double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, 840 double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->batch_size,
841 product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, 841 product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha,
842 product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); 842 product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
843 843
844 if (product->hops.at(i).h_useat == 2 || product->hops.at(i).h_useat == 4) // Boil or Whirlpool 844 if (product->hops.at(i).useat == 2 || product->hops.at(i).useat == 4) // Boil or Whirlpool
845 use = hop_useat[product->hops.at(i).h_useat] + QString(" %1 min").arg(product->hops.at(i).h_time); 845 use = hop_useat[product->hops.at(i).useat] + QString(" %1 min").arg(product->hops.at(i).time);
846 else if (product->hops.at(i).h_useat == 5) // Dryhop 846 else if (product->hops.at(i).useat == 5) // Dryhop
847 use = hop_useat[product->hops.at(i).h_useat] + QString(" %1 days").arg(product->hops.at(i).h_time / 1440); 847 use = hop_useat[product->hops.at(i).useat] + QString(" %1 days").arg(product->hops.at(i).time / 1440);
848 else 848 else
849 use = hop_useat[product->hops.at(i).h_useat]; 849 use = hop_useat[product->hops.at(i).useat];
850 850
851 if (product->hops.at(i).h_amount > 1) 851 if (product->hops.at(i).amount > 1)
852 amount = QString("%1 kg").arg(product->hops.at(i).h_amount, 1, 'f', 3); 852 amount = QString("%1 kg").arg(product->hops.at(i).amount, 1, 'f', 3);
853 else 853 else
854 amount = QString("%1 gr").arg(product->hops.at(i).h_amount * 1000, 1, 'f', 1); 854 amount = QString("%1 gr").arg(product->hops.at(i).amount * 1000, 1, 'f', 1);
855 855
856 painter.fillRect( 20, y, 715, 20, h_line); 856 painter.fillRect( 20, y, 715, 20, h_line);
857 painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, product->hops.at(i).h_name + " (" + product->hops.at(i).h_origin + ")"); 857 painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, product->hops.at(i).name + " (" + product->hops.at(i).origin + ")");
858 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(product->hops.at(i).h_alpha, 1, 'f', 1)); 858 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(product->hops.at(i).alpha, 1, 'f', 1));
859 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); 859 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1));
860 painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[product->hops.at(i).h_form]); 860 painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[product->hops.at(i).form]);
861 painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use); 861 painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use);
862 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); 862 painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount);
863 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); 863 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3));
864 y += 20; 864 y += 20;
865 } 865 }
1636 .arg(Utils::kettle_cm(l, product->eq_tun_volume, product->eq_tun_height), 1, 'f', 1)); 1636 .arg(Utils::kettle_cm(l, product->eq_tun_volume, product->eq_tun_height), 1, 'f', 1));
1637 if (numsalts > 0) 1637 if (numsalts > 0)
1638 checkLine(&painter, &y, QString(tr("Add brouwzouten"))); 1638 checkLine(&painter, &y, QString(tr("Add brouwzouten")));
1639 checkLine(&painter, &y, QString(tr("Add malts and dough-in"))); 1639 checkLine(&painter, &y, QString(tr("Add malts and dough-in")));
1640 for (int j = 0; j < product->hops.size(); j++) { 1640 for (int j = 0; j < product->hops.size(); j++) {
1641 if (product->hops.at(j).h_useat == HOP_USEAT_MASH) { 1641 if (product->hops.at(j).useat == HOP_USEAT_MASH) {
1642 checkLine(&painter, &y, QString(tr("Add %1 gram `%2` hop")).arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 1) 1642 checkLine(&painter, &y, QString(tr("Add %1 gram `%2` hop")).arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 1)
1643 .arg(product->hops.at(j).h_name)); 1643 .arg(product->hops.at(j).name));
1644 } 1644 }
1645 } 1645 }
1646 for (int j = 0; j < product->miscs.size(); j++) { 1646 for (int j = 0; j < product->miscs.size(); j++) {
1647 if ((product->miscs.at(j).use_use == MISC_USES_MASH) && (product->miscs.at(j).type != MISC_TYPES_WATER_AGENT)) { 1647 if ((product->miscs.at(j).use_use == MISC_USES_MASH) && (product->miscs.at(j).type != MISC_TYPES_WATER_AGENT)) {
1648 QString unit = (product->miscs.at(j).amount_is_weight) ? "gr":"ml"; 1648 QString unit = (product->miscs.at(j).amount_is_weight) ? "gr":"ml";
1706 .arg(Utils::kettle_cm(product->boil_size * factor * 1.04, product->eq_kettle_volume, product->eq_kettle_height), 1, 'f', 1), 1706 .arg(Utils::kettle_cm(product->boil_size * factor * 1.04, product->eq_kettle_volume, product->eq_kettle_height), 1, 'f', 1),
1707 QString(tr("cm"))); 1707 QString(tr("cm")));
1708 checkInput(&painter, &y, QString(tr("Target SG in boil kettle: ")) + strDensity(product->preboil_sg), QString(tr("SG"))); 1708 checkInput(&painter, &y, QString(tr("Target SG in boil kettle: ")) + strDensity(product->preboil_sg), QString(tr("SG")));
1709 checkInput(&painter, &y, "", QString(tr("pH"))); 1709 checkInput(&painter, &y, "", QString(tr("pH")));
1710 for (int i = 0; i < product->hops.size(); i++) { 1710 for (int i = 0; i < product->hops.size(); i++) {
1711 if (product->hops.at(i).h_useat == HOP_USEAT_FWH) { 1711 if (product->hops.at(i).useat == HOP_USEAT_FWH) {
1712 checkLine(&painter, &y, QString(tr("Add %1 gr `%2` hop after sparge")).arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1) 1712 checkLine(&painter, &y, QString(tr("Add %1 gr `%2` hop after sparge")).arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1)
1713 .arg(product->hops.at(i).h_name)); 1713 .arg(product->hops.at(i).name));
1714 } 1714 }
1715 } 1715 }
1716 1716
1717 if (checkSplit(&painter, &y, 1)) 1717 if (checkSplit(&painter, &y, 1))
1718 factor = 1; 1718 factor = 1;
1727 for (int i = 0; i < product->fermentables.size(); i++) { 1727 for (int i = 0; i < product->fermentables.size(); i++) {
1728 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOIL) 1728 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOIL)
1729 lines++; 1729 lines++;
1730 } 1730 }
1731 for (int i = 0; i < product->hops.size(); i++) { 1731 for (int i = 0; i < product->hops.size(); i++) {
1732 if (product->hops.at(i).h_useat == HOP_USEAT_BOIL || product->hops.at(i).h_useat == HOP_USEAT_AROMA) 1732 if (product->hops.at(i).useat == HOP_USEAT_BOIL || product->hops.at(i).useat == HOP_USEAT_AROMA)
1733 lines++; 1733 lines++;
1734 } 1734 }
1735 for (int i = 0; i < product->miscs.size(); i++) { 1735 for (int i = 0; i < product->miscs.size(); i++) {
1736 if (product->miscs.at(i).use_use == MISC_USES_BOIL) 1736 if (product->miscs.at(i).use_use == MISC_USES_BOIL)
1737 lines++; 1737 lines++;
1758 } 1758 }
1759 if (product->brew_cooling_method == 1) 1759 if (product->brew_cooling_method == 1)
1760 checkLine(&painter, &y, QString(tr("Place emersion chiller at 10 minutes before end of boil"))); 1760 checkLine(&painter, &y, QString(tr("Place emersion chiller at 10 minutes before end of boil")));
1761 } 1761 }
1762 for (int j = 0; j < product->hops.size(); j++) { 1762 for (int j = 0; j < product->hops.size(); j++) {
1763 if ((product->hops.at(j).h_useat == HOP_USEAT_BOIL || product->hops.at(j).h_useat == HOP_USEAT_AROMA) && product->hops.at(j).h_time == i) { 1763 if ((product->hops.at(j).useat == HOP_USEAT_BOIL || product->hops.at(j).useat == HOP_USEAT_AROMA) && product->hops.at(j).time == i) {
1764 if (i == 0) 1764 if (i == 0)
1765 checkLine(&painter, &y, QString(tr("%1 gr `%2` at flameout")).arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 2) 1765 checkLine(&painter, &y, QString(tr("%1 gr `%2` at flameout")).arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 2)
1766 .arg(product->hops.at(j).h_name)); 1766 .arg(product->hops.at(j).name));
1767 else 1767 else
1768 checkLine(&painter, &y, QString(tr("%1 gr `%2` at %3 minutes before end of boil")) 1768 checkLine(&painter, &y, QString(tr("%1 gr `%2` at %3 minutes before end of boil"))
1769 .arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 2).arg(product->hops.at(j).h_name).arg(i)); 1769 .arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 2).arg(product->hops.at(j).name).arg(i));
1770 } 1770 }
1771 } 1771 }
1772 for (int j = 0; j < product->miscs.size(); j++) { 1772 for (int j = 0; j < product->miscs.size(); j++) {
1773 if (product->miscs.at(j).use_use == MISC_USES_BOIL && product->miscs.at(j).time == i) { 1773 if (product->miscs.at(j).use_use == MISC_USES_BOIL && product->miscs.at(j).time == i) {
1774 QString unit = (product->miscs.at(j).amount_is_weight) ? "gr":"ml"; 1774 QString unit = (product->miscs.at(j).amount_is_weight) ? "gr":"ml";
1802 if (product->brew_whirlpool6) 1802 if (product->brew_whirlpool6)
1803 lines++; 1803 lines++;
1804 if (product->brew_whirlpool2) 1804 if (product->brew_whirlpool2)
1805 lines++; 1805 lines++;
1806 for (int i = 0; i < product->hops.size(); i++) { 1806 for (int i = 0; i < product->hops.size(); i++) {
1807 if (product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) 1807 if (product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL)
1808 lines++; 1808 lines++;
1809 } 1809 }
1810 if ((y + (lines * 20)) > painter.device()->height()) { 1810 if ((y + (lines * 20)) > painter.device()->height()) {
1811 printer->newPage(); 1811 printer->newPage();
1812 printHeader(&painter); 1812 printHeader(&painter);
1821 if (product->brew_whirlpool7 > 0) 1821 if (product->brew_whirlpool7 > 0)
1822 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes. Keep temp between 72 and 79°C")).arg(product->brew_whirlpool7, 1, 'f', 0)); 1822 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes. Keep temp between 72 and 79°C")).arg(product->brew_whirlpool7, 1, 'f', 0));
1823 if (product->brew_whirlpool6 > 0) 1823 if (product->brew_whirlpool6 > 0)
1824 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes. Keep temp between 60 and 66°C")).arg(product->brew_whirlpool6, 1, 'f', 0)); 1824 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes. Keep temp between 60 and 66°C")).arg(product->brew_whirlpool6, 1, 'f', 0));
1825 for (int i = 0; i < product->hops.size(); i++) { 1825 for (int i = 0; i < product->hops.size(); i++) {
1826 if (product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) 1826 if (product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL)
1827 checkLine(&painter, &y, QString(tr("%1 gr `%2` for %3 minutes in the whirlpool")) 1827 checkLine(&painter, &y, QString(tr("%1 gr `%2` for %3 minutes in the whirlpool"))
1828 .arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1).arg(product->hops.at(i).h_name) 1828 .arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1).arg(product->hops.at(i).name)
1829 .arg(product->hops.at(i).h_time)); 1829 .arg(product->hops.at(i).time));
1830 } 1830 }
1831 checkLine(&painter, &y, QString(tr("Cool to %1°C")).arg(product->brew_cooling_to, 1, 'f', 1)); 1831 checkLine(&painter, &y, QString(tr("Cool to %1°C")).arg(product->brew_cooling_to, 1, 'f', 1));
1832 if (product->brew_whirlpool2 > 0) 1832 if (product->brew_whirlpool2 > 0)
1833 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes.")).arg(product->brew_whirlpool2, 1, 'f', 0)); 1833 checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes.")).arg(product->brew_whirlpool2, 1, 'f', 0));
1834 } else { 1834 } else {
1977 lines = 0; 1977 lines = 0;
1978 for (int i = 0; i < product->fermentables.size(); i++) 1978 for (int i = 0; i < product->fermentables.size(); i++)
1979 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING) 1979 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING)
1980 lines++; 1980 lines++;
1981 for (int i = 0; i < product->hops.size(); i++) 1981 for (int i = 0; i < product->hops.size(); i++)
1982 if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) 1982 if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP)
1983 lines++; 1983 lines++;
1984 for (int i = 0; i < product->miscs.size(); i++) 1984 for (int i = 0; i < product->miscs.size(); i++)
1985 if (product->miscs.at(i).use_use == MISC_USES_SECONDARY) 1985 if (product->miscs.at(i).use_use == MISC_USES_SECONDARY)
1986 lines++; 1986 lines++;
1987 for (int i = 0; i < product->yeasts.size(); i++) { 1987 for (int i = 0; i < product->yeasts.size(); i++) {
2001 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING) 2001 if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING)
2002 checkLine(&painter, &y, QString(tr("Add %1 kg `%2`")).arg(product->fermentables.at(i).f_amount * factor, 1, 'f', 3) 2002 checkLine(&painter, &y, QString(tr("Add %1 kg `%2`")).arg(product->fermentables.at(i).f_amount * factor, 1, 'f', 3)
2003 .arg(product->fermentables.at(i).f_name)); 2003 .arg(product->fermentables.at(i).f_name));
2004 } 2004 }
2005 for (int i = 0; i < product->hops.size(); i++) { 2005 for (int i = 0; i < product->hops.size(); i++) {
2006 if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) { 2006 if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP) {
2007 checkLine(&painter, &y, QString(tr("Add %1 gram `%2` for %3 days")).arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1) 2007 checkLine(&painter, &y, QString(tr("Add %1 gram `%2` for %3 days")).arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1)
2008 .arg(product->hops.at(i).h_name).arg(product->hops.at(i).h_time / 1440)); 2008 .arg(product->hops.at(i).name).arg(product->hops.at(i).time / 1440));
2009 } 2009 }
2010 } 2010 }
2011 for (int i = 0; i < product->yeasts.size(); i++) { 2011 for (int i = 0; i < product->yeasts.size(); i++) {
2012 if (product->yeasts.at(i).y_use == YEAST_USE_TERTIARY) { 2012 if (product->yeasts.at(i).y_use == YEAST_USE_TERTIARY) {
2013 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) { 2013 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) {

mercurial