--- a/src/PrinterDialog.cpp Tue Apr 12 22:33:24 2022 +0200 +++ b/src/PrinterDialog.cpp Thu Apr 14 21:54:37 2022 +0200 @@ -16,6 +16,7 @@ */ #include "PrinterDialog.h" #include "config.h" +#include "global.h" #include <QPrintPreviewDialog> #include <QDebug> @@ -262,10 +263,6 @@ /* * Print yeast in the private yeast bank. */ - query.exec("SELECT brewery_name,my_yeastlab FROM profile_setup WHERE record = '1'"); - query.first(); - QString my_lab = query.value(1).toString(); - qDebug() << my_lab; printHeader(&painter); y = 120; @@ -282,7 +279,7 @@ painter.setFont(QFont("Helvetica", 9, QFont::Normal)); query.prepare("SELECT name,type,form,inventory,production_date,short_desc " "FROM inventory_yeasts WHERE inventory > 0 AND laboratory = :my_lab ORDER BY product_id"); - query.bindValue(":my_lab", my_lab); + query.bindValue(":my_lab", my_yeastlab); query.exec(); query.first(); for (int i = 0; i < query.size(); i++) { @@ -311,11 +308,8 @@ void PrinterDialog::printHeader(QPainter *painter) { - QSqlQuery query("SELECT brewery_logo,brewery_name FROM profile_setup"); - query.first(); - QByteArray logoByteArray = query.value(0).toByteArray(); QPixmap outPixmap = QPixmap(); - outPixmap.loadFromData(logoByteArray); + outPixmap.loadFromData(my_logoByteArray); int w = outPixmap.width(); int h = outPixmap.height(); /* Make sure to keep the logo aspect ratio */ @@ -330,11 +324,11 @@ /* The fat header line */ painter->setFont(QFont("Helvetica",18, QFont::Bold)); if (p_job == PR_SUPPLIES) { - painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Inventory") + " " + query.value(1).toString()); + painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Inventory") + " " + my_brewery_name); } else if (p_job == PR_YEASTBANK) { - painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Yeastbank") + " " + query.value(1).toString()); + painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Yeastbank") + " " + my_brewery_name); } else { - painter->drawText(120, 0, 500, 40, Qt::AlignLeft, "?? " + query.value(1).toString()); + painter->drawText(120, 0, 500, 40, Qt::AlignLeft, "?? " + my_brewery_name); } /* The first normal header line */ painter->setFont(QFont("Helvetica",10, QFont::Normal));