Fri, 20 May 2022 22:06:06 +0200
Version 0.2.1. Updated translations.
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Printer.cpp is part of bmsapp. |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "PrinterDialog.h" |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
18 | #include "Utils.h" |
158
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
19 | #include "EditRecipe.h" |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
20 | #include "EditProduct.h" |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | #include "config.h" |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
22 | #include "global.h" |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | #include <QPrintPreviewDialog> |
90
2396457a8167
Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
25 | #include <QDebug> |
2396457a8167
Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
26 | #include <QtSql> |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | PrinterDialog::PrinterDialog(int job, int rec, QWidget* parent) : QDialog(parent) |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | { |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | qDebug() << "PrinterDialog start job" << job << "rec" << rec; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | p_job = job; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | p_rec = rec; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | QPrinter printer(QPrinter::ScreenResolution); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | QPrintPreviewDialog preview(&printer, this); |
88
64cf5468fd22
Improve the CMakeLists.txt. Cleanup unused variables. Removed som debug messages.
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
38 | connect(&preview, &QPrintPreviewDialog::paintRequested, this, &PrinterDialog::printDocument); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | preview.exec(); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | } |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
88
64cf5468fd22
Improve the CMakeLists.txt. Cleanup unused variables. Removed som debug messages.
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
43 | PrinterDialog::~PrinterDialog() {} |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | void PrinterDialog::printDocument(QPrinter *printer) |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | { |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | qDebug() << "PrinterDialog printDocument()"; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | QRect rectangle; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | QRect boundingRect; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | QPainter painter; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | QString w; |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
54 | QSqlQuery query; |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
56 | const QColor c_header(255, 150, 100, 255); |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
57 | const QColor c_line1( 210, 245, 255, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
58 | const QColor c_line2( 255, 255, 210, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
59 | const QColor f_line( 250, 195, 65, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
60 | const QColor h_line( 100, 250, 65, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
61 | const QColor y_line( 175, 175, 255, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
62 | const QColor mw_line( 240, 140, 130, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
63 | const QColor mf_line( 95, 180, 25, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
64 | const QColor ms_line( 240, 250, 65, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
65 | const QColor mo_line( 210, 245, 255, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
66 | const QColor m_line( 175, 175, 255, 255); // also y_line |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
67 | const QColor w_line( 120, 255, 250, 255); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
68 | |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
69 | const QStringList y_unit({tr("pkg"), tr("gr"), tr("ml"), tr("ml"), tr("ml"), tr("ml"), tr("gr")}); |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
70 | const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" }); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
71 | const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" }); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | painter.begin(printer); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | qreal y = 0; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | if (p_job == PR_SUPPLIES) { |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
77 | /* |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
78 | * Print supplies in stock |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
79 | */ |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | double tot_fermentables = 0, tot_hops = 0, tot_yeasts = 0, tot_miscs = 0; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
82 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
83 | y = 120; |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | /* Fermentables supplies header */ |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | painter.setPen(Qt::black); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
87 | painter.fillRect( 0, y, 735, 20, c_header); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | painter.drawText( 0, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | painter.drawText( 90, y+4, 100, 20, Qt::AlignLeft, tr("Supplier")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | painter.drawText(190, y+4, 270, 20, Qt::AlignLeft, tr("Fermentable")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, tr("Stock")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, tr("Price/Kg")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, tr("Value")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
96 | query.exec("SELECT type,name,supplier,inventory,cost FROM inventory_fermentables WHERE inventory > 0 ORDER BY type,supplier,name"); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | query.first(); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | for (int i = 0 ; i < query.size() ; i++ ) { |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
99 | if ((y + 20) > painter.device()->height()) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
100 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
101 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
102 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
103 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
104 | painter.fillRect( 0, y, 735, 20, (i % 2) ? c_line1:c_line2); |
155
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
105 | painter.drawText( 0, y+4, 90, 20, Qt::AlignLeft, fermentable_types[query.value(0).toInt()]); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | painter.drawText( 90, y+4, 100, 20, Qt::AlignLeft, query.value(2).toString()); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | painter.drawText(190, y+4, 270, 20, Qt::AlignLeft, query.value(1).toString()); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | w = QString("%1 kg").arg(query.value(3).toDouble(), 10, 'f', 3); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | w = QString("%1 €").arg(query.value(4).toDouble(), 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | w = QString("%1 €").arg(query.value(3).toDouble() * query.value(4).toDouble(), 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | tot_fermentables += (query.value(3).toDouble() * query.value(4).toDouble()); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | query.next(); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | } |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
118 | painter.fillRect( 0, y, 735, 20, c_header); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | painter.drawText( 0, y+4, 100, 20, Qt::AlignLeft, tr("Total")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | w = QString("%1 €").arg(tot_fermentables, 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
124 | /* Hops supplies */ |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | query.exec("SELECT name,form,origin,inventory,cost FROM inventory_hops WHERE inventory > 0 ORDER BY origin,name"); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | query.first(); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
127 | if ((y + 80 + (query.size() * 20)) > painter.device()->height()) { /* Rows + header + footer + blank */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
128 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
129 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
130 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
131 | } else { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
132 | y += 40; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
133 | } |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | painter.setPen(Qt::black); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
136 | painter.fillRect( 0, y, 735, 20, c_header); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Country")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | painter.drawText(120, y+4, 260, 20, Qt::AlignLeft, tr("Hop name")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | painter.drawText(380, y+4, 80, 20, Qt::AlignLeft, tr("Form")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, tr("Stock")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, tr("Price/Kg")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, tr("Value")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | for (int i = 0; i < query.size(); i++) { |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
146 | if ((y + 20) > painter.device()->height()) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
147 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
148 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
149 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
150 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
151 | painter.fillRect( 0, y, 735, 20, (i % 2) ? c_line1:c_line2); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, query.value(2).toString()); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | painter.drawText(120, y+4, 260, 20, Qt::AlignLeft, query.value(0).toString()); |
155
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
154 | painter.drawText(380, y+4, 80, 20, Qt::AlignLeft, hop_forms[query.value(1).toInt()]); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | if (query.value(3).toDouble() < 0.6) |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | w = QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 10, 'f', 1); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | else |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | w = QString("%1 kg").arg(query.value(3).toDouble(), 10, 'f', 3); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | w = QString("%1 €").arg(query.value(4).toDouble(), 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | w = QString("%1 €").arg(query.value(3).toDouble() * query.value(4).toDouble(), 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | tot_hops += (query.value(3).toDouble() * query.value(4).toDouble()); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | query.next(); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | } |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
168 | painter.fillRect( 0, y, 735, 20, c_header); |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | painter.drawText( 0, y+4, 100, 20, Qt::AlignLeft, tr("Total")); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | w = QString("%1 €").arg(tot_hops, 8, 'f', 2); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | y += 20; |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
174 | /* Yeasts supplies */ |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | query.exec("SELECT name,laboratory,product_id,form,inventory,cost FROM inventory_yeasts WHERE inventory > 0 ORDER BY laboratory,product_id"); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | query.first(); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
177 | if ((y + 80 + (query.size() * 20)) > painter.device()->height()) { /* Rows + header + footer + blank */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
178 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
179 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
180 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
181 | } else { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
182 | y += 40; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
183 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
184 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
185 | painter.setPen(Qt::black); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
186 | painter.fillRect( 0, y, 735, 20, c_header); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
187 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Laboratory")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
188 | painter.drawText(120, y+4, 120, 20, Qt::AlignLeft, tr("Product")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
189 | painter.drawText(240, y+4, 220, 20, Qt::AlignLeft, tr("Yeast")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
190 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, tr("Stock")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
191 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, tr("Price/Kg")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
192 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, tr("Value")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
193 | y += 20; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
194 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
195 | for (int i = 0; i < query.size(); i++) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
196 | if ((y + 20) > painter.device()->height()) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
197 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
198 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
199 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
200 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
201 | painter.fillRect( 0, y, 735, 20, (i % 2) ? c_line1:c_line2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
202 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, query.value(1).toString()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
203 | painter.drawText(120, y+4, 120, 20, Qt::AlignLeft, query.value(2).toString()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
204 | painter.drawText(240, y+4, 220, 20, Qt::AlignLeft, query.value(0).toString()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
205 | if (query.value(3).toInt() == 0) |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
206 | w = QString("%1 %2").arg(query.value(4).toDouble(), 10, 'f', 1).arg(y_unit[query.value(3).toInt()]); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
207 | else |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
208 | w = QString("%1 %2").arg(query.value(4).toDouble() * 1000.0, 10, 'f', 1).arg(y_unit[query.value(3).toInt()]); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
209 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
210 | w = QString("%1 €").arg(query.value(5).toDouble(), 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
211 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
212 | w = QString("%1 €").arg(query.value(4).toDouble() * query.value(5).toDouble(), 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
213 | tot_yeasts += (query.value(4).toDouble() * query.value(5).toDouble()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
214 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
215 | query.next(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
216 | y += 20; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
217 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
218 | painter.fillRect( 0, y, 735, 20, c_header); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
219 | painter.drawText( 0, y+4, 100, 20, Qt::AlignLeft, tr("Total")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
220 | w = QString("%1 €").arg(tot_yeasts, 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
221 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
222 | y += 20; |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
224 | /* Miscs supplies */ |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | query.exec("SELECT name,type,amount_is_weight,inventory,cost FROM inventory_miscs WHERE inventory > 0 ORDER BY type,name"); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | query.first(); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
227 | if ((y + 80 + (query.size() * 20)) > painter.device()->height()) { /* Rows + header + footer + blank */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
228 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
229 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
230 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
231 | } else { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
232 | y += 40; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
233 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
234 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
235 | painter.setPen(Qt::black); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
236 | painter.fillRect( 0, y, 735, 20, c_header); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
237 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Type")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
238 | painter.drawText(120, y+4, 340, 20, Qt::AlignLeft, tr("Ingredient")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
239 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, tr("Stock")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
240 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, tr("Price/Kg")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
241 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, tr("Value")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
242 | y += 20; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
243 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
244 | for (int i = 0; i < query.size(); i++) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
245 | if ((y + 20) > painter.device()->height()) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
246 | printer->newPage(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
247 | printHeader(&painter); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
248 | y = 120; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
249 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
250 | painter.fillRect( 0, y, 735, 20, (i % 2) ? c_line1:c_line2); |
155
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
251 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, misc_types[query.value(1).toInt()]); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
252 | painter.drawText(120, y+4, 340, 20, Qt::AlignLeft, query.value(0).toString()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
253 | if (query.value(2).toInt()) |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
254 | w = QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 10, 'f', 1); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
255 | else |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
256 | w = QString("%1 ml").arg(query.value(3).toDouble() * 1000.0, 10, 'f', 1); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
257 | painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
258 | w = QString("%1 €").arg(query.value(4).toDouble(), 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
259 | painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
260 | w = QString("%1 €").arg(query.value(3).toDouble() * query.value(4).toDouble(), 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
261 | tot_miscs += (query.value(3).toDouble() * query.value(4).toDouble()); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
262 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
263 | query.next(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
264 | y += 20; |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
265 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
266 | painter.fillRect( 0, y, 735, 20, c_header); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
267 | painter.drawText( 0, y+4, 100, 20, Qt::AlignLeft, tr("Total")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
268 | w = QString("%1 €").arg(tot_miscs, 8, 'f', 2); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
269 | painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
270 | y += 20; |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
271 | |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
272 | } else if (p_job == PR_YEASTBANK) { |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
273 | /* |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
274 | * Print yeast in the private yeast bank. |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
275 | */ |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
276 | printHeader(&painter); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
277 | y = 120; |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
278 | |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
279 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
280 | painter.setPen(Qt::black); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
281 | painter.fillRect( 0, y, 735, 20, c_header); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
282 | painter.drawText( 0, y+4, 200, 20, Qt::AlignLeft, tr("Yeast")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
283 | painter.drawText(200, y+4, 230, 20, Qt::AlignLeft, tr("Description")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
284 | painter.drawText(430, y+4, 80, 20, Qt::AlignCenter, tr("Type")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
285 | painter.drawText(510, y+4, 80, 20, Qt::AlignCenter, tr("Form")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
286 | painter.drawText(590, y+4, 70, 20, Qt::AlignRight, tr("Stock")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
287 | painter.drawText(665, y+4, 70, 20, Qt::AlignLeft, tr("Date")); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
288 | y += 20; |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
289 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
290 | query.prepare("SELECT name,type,form,inventory,production_date,short_desc " |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
291 | "FROM inventory_yeasts WHERE inventory > 0 AND laboratory = :my_lab ORDER BY product_id"); |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
292 | query.bindValue(":my_lab", my_yeastlab); |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
293 | query.exec(); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
294 | query.first(); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
295 | for (int i = 0; i < query.size(); i++) { |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
296 | painter.fillRect( 0, y, 735, 20, (i % 2) ? c_line1:c_line2); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
297 | painter.drawText( 0, y+4, 200, 20, Qt::AlignLeft, query.value(0).toString()); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
298 | painter.drawText(200, y+4, 230, 20, Qt::AlignLeft, query.value(5).toString()); |
155
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
299 | painter.drawText(430, y+4, 80, 20, Qt::AlignCenter, yeast_types[query.value(1).toInt()]); |
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
300 | painter.drawText(510, y+4, 80, 20, Qt::AlignCenter, yeast_forms[query.value(2).toInt()]); |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
301 | |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
302 | if (query.value(2).toInt() == 0) |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
303 | w = QString("%1 %2").arg(query.value(3).toDouble(), 10, 'f', 1).arg(y_unit[query.value(2).toInt()]); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
304 | else |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
305 | w = QString("%1 %2").arg(query.value(3).toDouble() * 1000.0, 10, 'f', 1).arg(y_unit[query.value(2).toInt()]); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
306 | painter.drawText(590, y+4, 70, 20, Qt::AlignRight, w); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
307 | painter.drawText(665, y+4, 70, 20, Qt::AlignLeft, query.value(4).toString()); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
308 | query.next(); |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
309 | y += 20; |
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
310 | } |
158
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
311 | } else if (p_job == PR_RECIPE) { |
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
312 | |
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
313 | printHeader(&painter); |
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
314 | y = 120; |
160 | 315 | /* Generic header */ |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
316 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
317 | painter.setPen(Qt::black); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
318 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
319 | painter.drawText( 0, y+4, 735, 20, Qt::AlignCenter, tr("Recipe overview")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
320 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
321 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
322 | painter.fillRect( 0, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
323 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Brew type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
324 | painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, recipe_types[recipe->type]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
325 | painter.fillRect(435, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
326 | painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Efficiency")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
327 | painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 %").arg(recipe->efficiency, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
328 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
329 | painter.fillRect( 0, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
330 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Boil time")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
331 | painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 minutes.").arg(recipe->boil_time, 1, 'f', 0)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
332 | painter.fillRect(435, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
333 | painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Batch size")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
334 | painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L.").arg(recipe->batch_size, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
335 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
336 | painter.fillRect( 0, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
337 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Start SG")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
338 | painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_og, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
339 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
340 | painter.fillRect(435, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
341 | painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("End SG")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
342 | painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_fg, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
343 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
344 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
345 | painter.fillRect( 0, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
346 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Estimated Alcohol")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
347 | painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1%").arg(recipe->est_abv, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
348 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
349 | painter.fillRect(435, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
350 | painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Estimated CO2 vol")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
351 | painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_carb, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
352 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
353 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
354 | painter.fillRect( 0, y, 120, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
355 | painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Color (") + color_method[recipe->color_method] + ")"); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
356 | painter.fillRect(120, y, 180, 20, Utils::ebc_to_color(recipe->est_color)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
357 | if (recipe->est_color > 30) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
358 | painter.setPen(Qt::white); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
359 | painter.drawText(120, y+4, 90, 20, Qt::AlignLeft, QString("%1 EBC").arg(recipe->est_color, 1, 'f', 0)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
360 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
361 | painter.setPen(Qt::black); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
362 | painter.fillRect(435, y, 300, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
363 | painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("IBU (") + ibu_method[recipe->ibu_method] + ")"); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
364 | painter.drawText(555, y+4, 90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_ibu, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
365 | 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)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
366 | y += 40; |
158
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
367 | |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
368 | /* Fermentables */ |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
369 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
370 | painter.setPen(Qt::black); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
371 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
372 | painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, tr("Fermentable")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
373 | painter.drawText(265, y+4, 70, 20, Qt::AlignRight, tr("Percent")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
374 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("Yield")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
375 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
376 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
377 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
378 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
379 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
380 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
381 | double cost_fermentables = 0; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
382 | QString soort, amount, use; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
383 | for (int i = 0; i < recipe->fermentables.size(); i++) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
384 | double cost = recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
385 | cost_fermentables += cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
386 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
387 | if (recipe->fermentables.at(i).f_type == 0) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
388 | soort = fermentable_graintypes[recipe->fermentables.at(i).f_graintype]; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
389 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
390 | soort = fermentable_types[recipe->fermentables.at(i).f_type]; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
391 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
392 | if (recipe->fermentables.at(i).f_amount > 100) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
393 | amount = QString("%1 kg").arg(recipe->fermentables.at(i).f_amount, 1, 'f', 1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
394 | else if (recipe->fermentables.at(i).f_amount > 10) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
395 | amount = QString("%1 kg").arg(recipe->fermentables.at(i).f_amount, 1, 'f', 2); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
396 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
397 | amount = QString("%1 gr").arg(recipe->fermentables.at(i).f_amount * 1000, 1, 'f', 0); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
398 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
399 | painter.fillRect( 0, y, 735, 20, f_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
400 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
401 | painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->fermentables.at(i).f_name + |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
402 | QString(", %1 EBC (").arg(recipe->fermentables.at(i).f_color, 1, 'f', 0) + |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
403 | recipe->fermentables.at(i).f_supplier + ")"); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
404 | painter.drawText(265, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->fermentables.at(i).f_percentage, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
405 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->fermentables.at(i).f_yield, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
406 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, soort); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
407 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, fermentable_added[recipe->fermentables.at(i).f_added]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
408 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
409 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
410 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
411 | } |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
412 | painter.fillRect(670, y, 60, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
413 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_fermentables, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
414 | y += 40; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
415 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
416 | /* Hops */ |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
417 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
418 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
419 | painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, tr("Hop")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
420 | painter.drawText(265, y+4, 70, 20, Qt::AlignRight, tr("Alpha")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
421 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("IBU")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
422 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
423 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
424 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
425 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
426 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
427 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
428 | double cost_hops = 0; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
429 | for (int i = 0; i < recipe->hops.size(); i++) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
430 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
431 | double cost = recipe->hops.at(i).h_amount * recipe->hops.at(i).h_cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
432 | cost_hops += cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
433 | double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
434 | recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
435 | recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0, recipe->boil_time); |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
436 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
437 | if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) // Boil or Whirlpool |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
438 | use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 min").arg(recipe->hops.at(i).h_time); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
439 | else if (recipe->hops.at(i).h_useat == 5) // Dryhop |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
440 | use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 days").arg(recipe->hops.at(i).h_time / 1440); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
441 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
442 | use = hop_useat[recipe->hops.at(i).h_useat]; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
443 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
444 | if (recipe->hops.at(i).h_amount > 1) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
445 | amount = QString("%1 kg").arg(recipe->hops.at(i).h_amount, 1, 'f', 3); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
446 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
447 | amount = QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000, 1, 'f', 1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
448 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
449 | painter.fillRect( 0, y, 735, 20, h_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
450 | painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")"); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
451 | painter.drawText(265, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).h_alpha, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
452 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
453 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).h_form]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
454 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, use); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
455 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
456 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
457 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
458 | } |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
459 | painter.fillRect(670, y, 60, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
460 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_hops, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
461 | y += 40; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
462 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
463 | /* Yeasts */ |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
464 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
465 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
466 | painter.drawText( 0, y+4, 335, 20, Qt::AlignLeft, tr("Yeast")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
467 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, tr("Attn")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
468 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
469 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
470 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
471 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
472 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
473 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
474 | double cost_yeasts = 0; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
475 | for (int i = 0; i < recipe->yeasts.size(); i++) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
476 | double cost = recipe->yeasts.at(i).y_amount * recipe->yeasts.at(i).y_cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
477 | cost_yeasts += cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
478 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
479 | if (recipe->yeasts.at(i).y_form == 0) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
480 | amount = QString("%1 pack").arg(recipe->yeasts.at(i).y_amount, 1, 'f', 0); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
481 | else if (recipe->yeasts.at(i).y_form == 1 || recipe->yeasts.at(i).y_form == 6) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
482 | amount = QString("%1 gr").arg(recipe->yeasts.at(i).y_amount * 1000.0, 1, 'f', 1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
483 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
484 | amount = QString("%1 ml").arg(recipe->yeasts.at(i).y_amount * 1000.0, 1, 'f', 1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
485 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
486 | painter.fillRect( 0, y, 735, 20, y_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
487 | painter.drawText( 0, y+4, 260, 20, Qt::AlignLeft, recipe->yeasts.at(i).y_laboratory + " " + |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
488 | recipe->yeasts.at(i).y_product_id + " (" + |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
489 | recipe->yeasts.at(i).y_name + ")"); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
490 | painter.drawText(340, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->yeasts.at(i).y_attenuation, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
491 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, yeast_forms[recipe->yeasts.at(i).y_form]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
492 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, yeast_use[recipe->yeasts.at(i).y_use]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
493 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
494 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
495 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
496 | } |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
497 | painter.fillRect(670, y, 60, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
498 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_yeasts, 1, 'f', 3)); |
160 | 499 | |
500 | if ((y + 80 + (recipe->miscs.size() * 20)) > painter.device()->height()) { /* Rows + header + footer + blank */ | |
501 | printer->newPage(); | |
502 | printHeader(&painter); | |
503 | y = 120; | |
504 | } else { | |
505 | y += 40; | |
506 | } | |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
507 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
508 | /* Miscs */ |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
509 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
510 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
511 | painter.drawText( 0, y+4, 410, 20, Qt::AlignLeft, tr("Misc ingredient")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
512 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, tr("Type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
513 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, tr("Use at")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
514 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, tr("Amount")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
515 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, tr("Cost")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
516 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
517 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
518 | double cost_miscs = 0; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
519 | for (int i = 0; i < recipe->miscs.size(); i++) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
520 | double cost = recipe->miscs.at(i).m_amount * recipe->miscs.at(i).m_cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
521 | cost_miscs += cost; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
522 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
523 | if (recipe->miscs.at(i).m_use_use == 2) |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
524 | use = misc_uses[recipe->miscs.at(i).m_use_use] + QString(" %1 min").arg(recipe->miscs.at(i).m_time); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
525 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
526 | use = misc_uses[recipe->miscs.at(i).m_use_use]; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
527 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
528 | if (recipe->miscs.at(i).m_type == 4) // Water agent |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
529 | painter.fillRect( 0, y, 735, 20, mw_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
530 | else if (recipe->miscs.at(i).m_type == 3) // Fining |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
531 | painter.fillRect( 0, y, 735, 20, mf_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
532 | else if (recipe->miscs.at(i).m_type < 3 || recipe->miscs.at(i).m_type == 5) // Spice, Herb, Flavour, Yeast nutrient |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
533 | painter.fillRect( 0, y, 735, 20, ms_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
534 | else |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
535 | painter.fillRect( 0, y, 735, 20, mo_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
536 | painter.drawText( 0, y+4, 410, 20, Qt::AlignLeft, recipe->miscs.at(i).m_name); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
537 | painter.drawText(415, y+4, 90, 20, Qt::AlignLeft, misc_types[recipe->miscs.at(i).m_type]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
538 | painter.drawText(510, y+4, 90, 20, Qt::AlignLeft, use); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
539 | painter.drawText(605, y+4, 60, 20, Qt::AlignRight, |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
540 | 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")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
541 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
542 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
543 | } |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
544 | painter.fillRect(670, y, 60, 20, c_line1); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
545 | painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_miscs, 1, 'f', 3)); |
160 | 546 | |
547 | if ((y + 60 + (recipe->mashs.size() * 20)) > painter.device()->height()) { /* Rows + header + blank */ | |
548 | printer->newPage(); | |
549 | printHeader(&painter); | |
550 | y = 120; | |
551 | } else { | |
552 | y += 40; | |
553 | } | |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
554 | |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
555 | /* Mash */ |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
556 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
557 | painter.fillRect( 0, y, 735, 20, c_header); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
558 | painter.drawText( 0, y+4, 160, 20, Qt::AlignLeft, tr("Mash step")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
559 | painter.drawText(165, y+4, 90, 20, Qt::AlignLeft, tr("Step type")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
560 | painter.drawText(260, y+4, 60, 20, Qt::AlignRight, tr("Start °C")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
561 | painter.drawText(325, y+4, 60, 20, Qt::AlignRight, tr("End °C")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
562 | painter.drawText(390, y+4, 60, 20, Qt::AlignRight, tr("Time")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
563 | painter.drawText(455, y+4, 60, 20, Qt::AlignRight, tr("Ramp")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
564 | painter.drawText(520, y+4, 60, 20, Qt::AlignRight, tr("L/kg")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
565 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, tr("Inf/dec L.")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
566 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, tr("Inf/dec °C")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
567 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
568 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
569 | for (int i = 0; i < recipe->mashs.size(); i++) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
570 | painter.fillRect( 0, y, 735, 20, m_line); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
571 | painter.drawText( 0, y+4, 160, 20, Qt::AlignLeft, recipe->mashs.at(i).step_name); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
572 | painter.drawText(165, y+4, 90, 20, Qt::AlignLeft, step_types[recipe->mashs.at(i).step_type]); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
573 | painter.drawText(260, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_temp, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
574 | painter.drawText(325, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).end_temp, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
575 | painter.drawText(390, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_time, 1, 'f', 0)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
576 | painter.drawText(455, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).ramp_time, 1, 'f', 0)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
577 | painter.drawText(520, y+4, 60, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_wg_ratio, 1, 'f', 2)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
578 | if (recipe->mashs.at(i).step_type != 1) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
579 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_infuse_amount, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
580 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->mashs.at(i).step_infuse_temp, 1, 'f', 1)); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
581 | } |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
582 | y += 20; |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
583 | } |
160 | 584 | |
585 | if ((y + 80 + ((recipe->w2_amount > 0) ? 40:0)) > painter.device()->height()) { /* waters + header + blank */ | |
586 | printer->newPage(); | |
587 | printHeader(&painter); | |
588 | y = 120; | |
589 | } else { | |
590 | y += 40; | |
591 | } | |
592 | ||
593 | /* Water */ | |
594 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); | |
595 | painter.fillRect( 0, y, 735, 20, c_header); | |
596 | painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Water source")); | |
597 | painter.drawText(135, y+4, 70, 20, Qt::AlignRight, tr("Volume")); | |
598 | painter.drawText(210, y+4, 70, 20, Qt::AlignRight, tr("Ca")); | |
599 | painter.drawText(285, y+4, 70, 20, Qt::AlignRight, tr("Mg")); | |
600 | painter.drawText(360, y+4, 70, 20, Qt::AlignRight, tr("CaCO3")); | |
601 | painter.drawText(435, y+4, 70, 20, Qt::AlignRight, tr("Na")); | |
602 | painter.drawText(510, y+4, 70, 20, Qt::AlignRight, tr("Cl")); | |
603 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, tr("SO4")); | |
604 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, tr("pH")); | |
605 | y += 20; | |
606 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); | |
607 | painter.fillRect( 0, y, 735, 20, w_line); | |
608 | painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, recipe->w1_name); | |
609 | painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->w1_amount, 1, 'f', 1)); | |
610 | painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_calcium, 1, 'f', 1)); | |
611 | painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_magnesium, 1, 'f', 1)); | |
612 | painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_total_alkalinity, 1, 'f', 1)); | |
613 | painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_sodium, 1, 'f', 1)); | |
614 | painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_chloride, 1, 'f', 1)); | |
615 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_sulfate, 1, 'f', 1)); | |
616 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_ph, 1, 'f', 2)); | |
617 | y += 20; | |
618 | if (recipe->w2_amount > 0) { | |
619 | /* | |
620 | * If there is dillution water, show it and the mixed result too. | |
621 | */ | |
622 | painter.fillRect( 0, y, 735, 20, w_line); | |
623 | painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, recipe->w2_name); | |
624 | painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->w2_amount, 1, 'f', 1)); | |
625 | painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_calcium, 1, 'f', 1)); | |
626 | painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_magnesium, 1, 'f', 1)); | |
627 | painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_total_alkalinity, 1, 'f', 1)); | |
628 | painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_sodium, 1, 'f', 1)); | |
629 | painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_chloride, 1, 'f', 1)); | |
630 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_sulfate, 1, 'f', 1)); | |
631 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_ph, 1, 'f', 2)); | |
632 | y += 20; | |
633 | painter.fillRect( 0, y, 735, 20, w_line); | |
634 | painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Mixed water")); | |
635 | painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->wg_amount, 1, 'f', 1)); | |
636 | painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_calcium, 1, 'f', 1)); | |
637 | painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_magnesium, 1, 'f', 1)); | |
638 | painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_total_alkalinity, 1, 'f', 1)); | |
639 | painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_sodium, 1, 'f', 1)); | |
640 | painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_chloride, 1, 'f', 1)); | |
641 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_sulfate, 1, 'f', 1)); | |
642 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_ph, 1, 'f', 2)); | |
643 | y += 20; | |
644 | } | |
645 | painter.fillRect( 0, y, 735, 20, w_line); | |
646 | painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Treated water")); | |
647 | painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_calcium, 1, 'f', 1)); | |
648 | painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_magnesium, 1, 'f', 1)); | |
649 | painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_total_alkalinity, 1, 'f', 1)); | |
650 | painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_sodium, 1, 'f', 1)); | |
651 | painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_chloride, 1, 'f', 1)); | |
652 | painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_sulfate, 1, 'f', 1)); | |
653 | painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_ph, 1, 'f', 2)); | |
654 | y += 20; | |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
655 | } |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
656 | |
160 | 657 | /* |
658 | * Print recipe notes if present. | |
659 | */ | |
660 | if (recipe->notes.length()) { | |
661 | QStringList lines = recipe->notes.split("\n"); | |
662 | ||
663 | if (lines.size() && recipe->notes != "") { | |
664 | if ((y + 80 + (lines.size() * 20)) > painter.device()->height()) { | |
665 | printer->newPage(); | |
666 | printHeader(&painter); | |
667 | y = 120; | |
668 | } else { | |
669 | y += 40; | |
670 | } | |
671 | ||
672 | /* Notes header */ | |
673 | painter.setFont(QFont("Helvetica", 9, QFont::Bold)); | |
674 | painter.setPen(Qt::black); | |
675 | painter.fillRect( 0, y, 735, 20, c_header); | |
676 | painter.drawText( 0, y+4, 735, 20, Qt::AlignCenter, tr("Recipe notes")); | |
677 | y += 20; | |
678 | painter.setFont(QFont("Helvetica", 9, QFont::Normal)); | |
679 | for (int i = 0; i < lines.size(); i++) { | |
680 | painter.fillRect( 0, y, 735, 20, c_line1); | |
681 | painter.drawText( 0, y+4, 735, 20, Qt::AlignLeft, lines[i]); | |
682 | y += 20; | |
683 | } | |
684 | } | |
685 | } | |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
686 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
687 | painter.end(); |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
688 | } |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
689 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
690 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
691 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
692 | void PrinterDialog::printHeader(QPainter *painter) |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
693 | { |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
694 | QPixmap outPixmap = QPixmap(); |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
695 | outPixmap.loadFromData(my_logoByteArray); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
696 | int w = outPixmap.width(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
697 | int h = outPixmap.height(); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
698 | /* Make sure to keep the logo aspect ratio */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
699 | if (w == h) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
700 | painter->drawPixmap(0, 0, 100, 100, outPixmap); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
701 | } else if (w > h) { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
702 | painter->drawPixmap(0, 0, 100, (h * 100) / w, outPixmap); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
703 | } else { |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
704 | painter->drawPixmap(0, 0, (w * 100) / h, 100, outPixmap); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
705 | } |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
706 | |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
707 | /* The fat header line */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
708 | painter->setFont(QFont("Helvetica",18, QFont::Bold)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
709 | if (p_job == PR_SUPPLIES) { |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
710 | painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Inventory") + " " + my_brewery_name); |
54
bba7be9034be
Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
711 | } else if (p_job == PR_YEASTBANK) { |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
712 | painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Yeastbank") + " " + my_brewery_name); |
158
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
713 | } else if (p_job == PR_RECIPE) { |
24bc2de721d9
Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
714 | painter->drawText(120, 0, 500, 40, Qt::AlignLeft, recipe->name); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
715 | } else { |
133
08635b028dcf
Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
716 | painter->drawText(120, 0, 500, 40, Qt::AlignLeft, "?? " + my_brewery_name); |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
717 | } |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
718 | /* The first normal header line */ |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
719 | painter->setFont(QFont("Helvetica",10, QFont::Normal)); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
720 | painter->drawText(120,35, 80, 20, Qt::AlignLeft, tr("Date and time")); |
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
721 | painter->drawText(200,35, 400, 20, Qt::AlignLeft, ": " + QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm")); |
159
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
722 | if (p_job == PR_RECIPE) { |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
723 | painter->drawText(120,55, 80, 20, Qt::AlignLeft, tr("Beer style")); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
724 | painter->drawText(200,55, 400, 20, Qt::AlignLeft, ": " + recipe->st_name); |
231f5c8002e3
Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
725 | } |
53
d36879f13d32
Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
726 | /* The report itself may print more lines from y = 55. */ |
52
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
727 | } |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
728 | |
ff7b3a41c9b5
After several days experimenting, trials and a lot of errors, a working and nice looking printer support has been added to the application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
729 |