src/PrinterDialog.cpp

Wed, 27 Apr 2022 08:54:17 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 27 Apr 2022 08:54:17 +0200
changeset 163
6cccd340ea8c
parent 160
2b62a032079f
child 175
f1ed3a2a94e9
permissions
-rw-r--r--

Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.

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"
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
20 #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
21 #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
22
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 #include <QPrintPreviewDialog>
90
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
24 #include <QDebug>
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
25 #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
26
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 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
29 {
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 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
31
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 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
33 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
34
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 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
36 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
37 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
38 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
39 }
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
88
64cf5468fd22 Improve the CMakeLists.txt. Cleanup unused variables. Removed som debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
42 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
43
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 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
46 {
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 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
48
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 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
50 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
51 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
52 QString w;
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
53 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
54
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
68 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
69 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
70 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
71
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 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
73 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
74
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 if (p_job == PR_SUPPLIES) {
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
76 /*
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
77 * Print supplies in stock
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
78 */
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
79 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
80
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
81 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
82 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
83 /* 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
84 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
85 painter.setPen(Qt::black);
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
95 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
96 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
97 for (int i = 0 ; i < query.size() ; i++ ) {
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
98 if ((y + 20) > painter.device()->height()) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
99 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
100 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
101 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
102 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 }
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
117 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
118 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
119 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
120 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
121 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
122
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
123 /* 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
124 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
125 query.first();
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
126 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
127 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
128 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
129 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
130 } else {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
131 y += 40;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
132 }
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
133 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
134 painter.setPen(Qt::black);
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 for (int i = 0; i < query.size(); i++) {
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
145 if ((y + 20) > painter.device()->height()) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
146 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
147 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
148 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
149 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 }
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
167 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
168 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
169 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
170 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
171 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
172
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
173 /* 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
174 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
175 query.first();
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
176 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
177 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
178 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
179 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
180 } else {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
181 y += 40;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
182 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
183 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
184 painter.setPen(Qt::black);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
185 painter.fillRect( 0, y, 735, 20, c_header);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
186 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
187 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
188 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
189 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
190 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
191 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
192 y += 20;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
193 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
194 for (int i = 0; i < query.size(); i++) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
195 if ((y + 20) > painter.device()->height()) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
196 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
197 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
198 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
199 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
200 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
201 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
202 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
203 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
204 if (query.value(3).toInt() == 0)
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
205 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
206 else
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
207 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
208 painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
209 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
210 painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
211 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
212 tot_yeasts += (query.value(4).toDouble() * query.value(5).toDouble());
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
213 painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
214 query.next();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
215 y += 20;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
216 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
217 painter.fillRect( 0, y, 735, 20, c_header);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
218 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
219 w = QString("%1 €").arg(tot_yeasts, 8, 'f', 2);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
220 painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
221 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
222
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
223 /* 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
224 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
225 query.first();
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
226 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
227 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
228 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
229 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
230 } else {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
231 y += 40;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
232 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
233 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
234 painter.setPen(Qt::black);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
235 painter.fillRect( 0, y, 735, 20, c_header);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
236 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
237 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
238 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
239 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
240 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
241 y += 20;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
242 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
243 for (int i = 0; i < query.size(); i++) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
244 if ((y + 20) > painter.device()->height()) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
245 printer->newPage();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
246 printHeader(&painter);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
247 y = 120;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
248 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
249 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
250 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
251 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
252 if (query.value(2).toInt())
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
253 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
254 else
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
255 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
256 painter.drawText(460, y+4, 115, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
257 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
258 painter.drawText(575, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
259 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
260 tot_miscs += (query.value(3).toDouble() * query.value(4).toDouble());
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
261 painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
262 query.next();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
263 y += 20;
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
264 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
265 painter.fillRect( 0, y, 735, 20, c_header);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
266 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
267 w = QString("%1 €").arg(tot_miscs, 8, 'f', 2);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
268 painter.drawText(655, y+4, 80, 20, Qt::AlignRight, w);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
269 y += 20;
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
270
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
271 } else if (p_job == PR_YEASTBANK) {
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
272 /*
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
273 * Print yeast in the private yeast bank.
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
274 */
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
275 printHeader(&painter);
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
276 y = 120;
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
277
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
278 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
279 painter.setPen(Qt::black);
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
280 painter.fillRect( 0, y, 735, 20, c_header);
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
281 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
282 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
283 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
284 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
285 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
286 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
287 y += 20;
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
288 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
289 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
290 "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
291 query.bindValue(":my_lab", my_yeastlab);
54
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
292 query.exec();
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
293 query.first();
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
294 for (int i = 0; i < query.size(); i++) {
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
295 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
296 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
297 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
298 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
299 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
300
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
301 if (query.value(2).toInt() == 0)
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
302 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
303 else
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
304 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
305 painter.drawText(590, y+4, 70, 20, Qt::AlignRight, w);
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
306 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
307 query.next();
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
308 y += 20;
bba7be9034be Added print private yeastbank
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
309 }
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
310 } 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
311
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 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
313 y = 120;
160
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
314 /* Generic header */
159
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
315 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
316 painter.setPen(Qt::black);
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
317 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
318 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
319 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
320 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
321 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
322 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
323 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
324 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
325 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
326 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
327 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
328 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
329 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
330 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
331 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
332 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
333 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
334 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
335 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
336 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
337 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
338 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_og_min, 1, 'f', 3).arg(recipe->st_og_max, 1, 'f', 3));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
339 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
340 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
341 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
342 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_fg_min, 1, 'f', 3).arg(recipe->st_fg_max, 1, 'f', 3));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
343 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
344 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
345 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
346 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
347 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_abv_min, 1, 'f', 1).arg(recipe->st_abv_max, 1, 'f', 1));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
348 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
349 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
350 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
351 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_carb_min, 1, 'f', 1).arg(recipe->st_carb_max, 1, 'f', 1));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
352 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
353 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
354 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
355 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
356 if (recipe->est_color > 30)
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
357 painter.setPen(Qt::white);
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
358 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
359 painter.drawText(210, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_color_min, 1, 'f', 0).arg(recipe->st_color_max, 1, 'f', 0));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
360 painter.setPen(Qt::black);
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
361 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
362 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
363 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
364 painter.drawText(645, y+4, 90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_ibu_min, 1, 'f', 0).arg(recipe->st_ibu_max, 1, 'f', 0));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
365 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
366
159
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
367 /* Fermentables */
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
368 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
369 painter.setPen(Qt::black);
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
379 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
380 double cost_fermentables = 0;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
381 QString soort, amount, use;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
382 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
383 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
384 cost_fermentables += cost;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
385
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
386 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
387 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
388 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
389 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
390
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
391 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
392 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
393 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
394 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
395 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
396 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
397
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
398 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
399
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
400 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
401 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
402 recipe->fermentables.at(i).f_supplier + ")");
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
403 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
404 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
405 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
406 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
407 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
408 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
409 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
410 }
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
411 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
412 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
413 y += 40;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
414
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
415 /* Hops */
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
416 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
417 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
426 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
427 double cost_hops = 0;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
428 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
429
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
430 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
431 cost_hops += cost;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
432 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
433 recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha,
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
434 recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0);
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
435
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
436 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
437 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
438 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
439 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
440 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
441 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
442
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
443 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
444 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
445 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
446 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
447
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
457 }
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
458 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
459 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
460 y += 40;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
461
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
462 /* Yeasts */
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
463 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
464 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
465 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
466 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
467 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
468 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
469 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
470 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
471 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
472 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
473 double cost_yeasts = 0;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
474 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
475 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
476 cost_yeasts += cost;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
477
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
478 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
479 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
480 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
481 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
482 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
483 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
484
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
485 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
486 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
487 recipe->yeasts.at(i).y_product_id + " (" +
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
488 recipe->yeasts.at(i).y_name + ")");
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
489 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
490 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
491 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
492 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
493 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
494 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
495 }
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
496 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
497 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_yeasts, 1, 'f', 3));
160
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
498
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
499 if ((y + 80 + (recipe->miscs.size() * 20)) > painter.device()->height()) { /* Rows + header + footer + blank */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
500 printer->newPage();
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
501 printHeader(&painter);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
502 y = 120;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
503 } else {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
504 y += 40;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
505 }
159
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
506
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
507 /* Miscs */
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
508 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
509 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
510 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
511 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
512 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
513 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
514 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
515 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
516 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
517 double cost_miscs = 0;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
518 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
519 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
520 cost_miscs += cost;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
521
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
522 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
523 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
524 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
525 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
526
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
527 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
528 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
529 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
530 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
531 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
532 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
533 else
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
534 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
535 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
536 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
537 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
538 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
539 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
540 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
541 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
542 }
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
543 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
544 painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost_miscs, 1, 'f', 3));
160
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
545
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
546 if ((y + 60 + (recipe->mashs.size() * 20)) > painter.device()->height()) { /* Rows + header + blank */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
547 printer->newPage();
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
548 printHeader(&painter);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
549 y = 120;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
550 } else {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
551 y += 40;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
552 }
159
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
553
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
554 /* Mash */
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
555 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564 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
565 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
566 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
567 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
568 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
569 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
570 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
571 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
572 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
573 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
574 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
575 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
576 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
577 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
578 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
579 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
580 }
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
581 y += 20;
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
582 }
160
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
583
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
584 if ((y + 80 + ((recipe->w2_amount > 0) ? 40:0)) > painter.device()->height()) { /* waters + header + blank */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
585 printer->newPage();
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
586 printHeader(&painter);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
587 y = 120;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
588 } else {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
589 y += 40;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
590 }
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
591
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
592 /* Water */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
593 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
594 painter.fillRect( 0, y, 735, 20, c_header);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
595 painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Water source"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
596 painter.drawText(135, y+4, 70, 20, Qt::AlignRight, tr("Volume"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
597 painter.drawText(210, y+4, 70, 20, Qt::AlignRight, tr("Ca"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
598 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, tr("Mg"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
599 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, tr("CaCO3"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
600 painter.drawText(435, y+4, 70, 20, Qt::AlignRight, tr("Na"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
601 painter.drawText(510, y+4, 70, 20, Qt::AlignRight, tr("Cl"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
602 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, tr("SO4"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
603 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, tr("pH"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
604 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
605 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
606 painter.fillRect( 0, y, 735, 20, w_line);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
607 painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, recipe->w1_name);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
608 painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->w1_amount, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
609 painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_calcium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
610 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_magnesium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
611 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_total_alkalinity, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
612 painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_sodium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
613 painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_chloride, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
614 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_sulfate, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
615 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w1_ph, 1, 'f', 2));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
616 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
617 if (recipe->w2_amount > 0) {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
618 /*
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
619 * If there is dillution water, show it and the mixed result too.
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
620 */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
621 painter.fillRect( 0, y, 735, 20, w_line);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
622 painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, recipe->w2_name);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
623 painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->w2_amount, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
624 painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_calcium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
625 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_magnesium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
626 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_total_alkalinity, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
627 painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_sodium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
628 painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_chloride, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
629 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_sulfate, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
630 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->w2_ph, 1, 'f', 2));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
631 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
632 painter.fillRect( 0, y, 735, 20, w_line);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
633 painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Mixed water"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
634 painter.drawText(135, y+4, 70, 20, Qt::AlignRight, QString("%1 L").arg(recipe->wg_amount, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
635 painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_calcium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
636 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_magnesium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
637 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_total_alkalinity, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
638 painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_sodium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
639 painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_chloride, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
640 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_sulfate, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
641 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wg_ph, 1, 'f', 2));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
642 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
643 }
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
644 painter.fillRect( 0, y, 735, 20, w_line);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
645 painter.drawText( 0, y+4, 135, 20, Qt::AlignLeft, tr("Treated water"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
646 painter.drawText(210, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_calcium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
647 painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_magnesium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
648 painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_total_alkalinity, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
649 painter.drawText(435, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_sodium, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
650 painter.drawText(510, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_chloride, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
651 painter.drawText(585, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_sulfate, 1, 'f', 1));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
652 painter.drawText(660, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(recipe->wb_ph, 1, 'f', 2));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
653 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
654 }
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
160
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
656 /*
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
657 * Print recipe notes if present.
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
658 */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
659 if (recipe->notes.length()) {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
660 QStringList lines = recipe->notes.split("\n");
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
661
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
662 if (lines.size() && recipe->notes != "") {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
663 if ((y + 80 + (lines.size() * 20)) > painter.device()->height()) {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
664 printer->newPage();
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
665 printHeader(&painter);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
666 y = 120;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
667 } else {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
668 y += 40;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
669 }
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
670
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
671 /* Notes header */
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
672 painter.setFont(QFont("Helvetica", 9, QFont::Bold));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
673 painter.setPen(Qt::black);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
674 painter.fillRect( 0, y, 735, 20, c_header);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
675 painter.drawText( 0, y+4, 735, 20, Qt::AlignCenter, tr("Recipe notes"));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
676 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
677 painter.setFont(QFont("Helvetica", 9, QFont::Normal));
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
678 for (int i = 0; i < lines.size(); i++) {
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
679 painter.fillRect( 0, y, 735, 20, c_line1);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
680 painter.drawText( 0, y+4, 735, 20, Qt::AlignLeft, lines[i]);
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
681 y += 20;
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
682 }
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
683 }
2b62a032079f Completed print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
684 }
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
685
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 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
687 }
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
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
691 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
692 {
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 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
694 outPixmap.loadFromData(my_logoByteArray);
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
695 int w = outPixmap.width();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
696 int h = outPixmap.height();
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
697 /* Make sure to keep the logo aspect ratio */
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
698 if (w == h) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
699 painter->drawPixmap(0, 0, 100, 100, outPixmap);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
700 } else if (w > h) {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
701 painter->drawPixmap(0, 0, 100, (h * 100) / w, outPixmap);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
702 } else {
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
703 painter->drawPixmap(0, 0, (w * 100) / h, 100, outPixmap);
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
704 }
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
705
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
706 /* The fat header line */
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
707 painter->setFont(QFont("Helvetica",18, QFont::Bold));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
708 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
709 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
710 } 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
711 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
712 } 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
713 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
714 } 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
715 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
716 }
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
717 /* The first normal header line */
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
718 painter->setFont(QFont("Helvetica",10, QFont::Normal));
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
719 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
720 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
721 if (p_job == PR_RECIPE) {
231f5c8002e3 Added the largest part of print recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
722 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
723 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
724 }
53
d36879f13d32 Completed printing inventory supplies.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
725 /* 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
726 }
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

mercurial