Fix checklist mash steps overflow.

Thu, 22 Sep 2022 11:33:45 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 22 Sep 2022 11:33:45 +0200
changeset 405
2c828cc3d943
parent 404
47f1259378fe
child 406
6ff0f0a381b2

Fix checklist mash steps overflow.

src/PrinterDialog.cpp file | annotate | diff | comparison | revisions
--- a/src/PrinterDialog.cpp	Sat Aug 27 13:54:01 2022 +0200
+++ b/src/PrinterDialog.cpp	Thu Sep 22 11:33:45 2022 +0200
@@ -1663,10 +1663,42 @@
 	    }
 	}
 	checkLine(&painter, &y, QString(tr("Mill the malts")));
-	y += 20;
+
+	int lines = 0;
+	int loop = 0;
+	for (int i = 0; i < product->mashs.size(); i++) {
+	    if (loop == 0) {
+		lines += 3;
+		if (numsalts > 0)
+		    lines++;
+		for (int j = 0; j < product->hops.size(); j++) {
+		    if (product->hops.at(j).useat == HOP_USEAT_MASH) {
+			lines++;
+		    }
+		}
+		for (int j = 0; j < product->miscs.size(); j++) {
+		    if ((product->miscs.at(j).use_use == MISC_USES_MASH) && (product->miscs.at(j).type != MISC_TYPES_WATER_AGENT)) {
+			lines++;
+		    }
+		}
+	    } else {
+		lines++;
+	    }
+	    lines++;
+	    loop++;
+	}
+	lines++;
+	qDebug() << "check" << lines << y + (lines * 20) << painter.device()->height();
+        if ((y + (lines * 20)) > painter.device()->height()) {
+            printer->newPage();
+            printHeader(&painter);
+            y = 120;
+        } else {
+            y += 20;
+        }
 
 	checkHeader(&painter, &y, tr("Mash"));
-	int loop = 0;
+	loop = 0;
 	double l, mvol = 0, msugars = 0;
 	for (int i = 0; i < product->mashs.size(); i++) {
 	    if (product->mashs.at(i).step_type == 0)
@@ -1761,7 +1793,7 @@
 	if (checkSplit(&painter, &y, 1))
 	    factor = 1;
 	/* Boil, how much space do we need */
-	int lines = 0;
+	lines = 0;
 	if (product->boil_time == 0) {
 	   lines = 3;
 	} else {

mercurial