summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2014-07-25 15:59:12 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-25 07:23:39 -0700
commit050b1b71ffe92b76b98c768e7d30e2a219251a72 (patch)
tree9d8105ffe6302d36da135f4649ff440428e46edc /qt-ui
parentce42e32bceb298201101f1674181b25e380eac0d (diff)
downloadsubsurface-050b1b71ffe92b76b98c768e7d30e2a219251a72.tar.gz
PrintLayout: fix a potential bug in the recent table print update
There is a weird QPicture dependency; we need to offset a page by headingRowHeightD2, which is half the heading height. The same doesn't make sense if we are rendering the table widget directly to the printer-painter. Moving the offset inside 'pageIndexes' is less desirable. The bug itself manifests when a top margin is set on Win32, while on Linux it's more obvious. On new page start, a fixed height from the last dive on the previous page becomes visible even if the math seems correct. Offsetting both the page index and the vertical position at which the QPicture is placed fixes that. If 'table.render(&painter...)' is used the bug also goes away and our 'pageIndexes' start to make sense again, but we want to use QPicture so that the table is in vector. I don't have a good explanation why this happens! Tested on Ubuntu 12.04 and Win7. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printlayout.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 277f48054..7c0894db5 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -375,9 +375,8 @@ void PrintLayout::printTable()
* use 10% each, then the sum of passes[] here should be 80%.
* two should be enough! */
const int passes[] = { 70, 10 };
- int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings;
+ int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings, headingRowHeightD2;
bool isHeading = false;
- int headingRowH;
for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) {
progress = headings = accH = 0;
@@ -386,7 +385,7 @@ void PrintLayout::printTable()
rowH = table.rowHeight(i);
accH += rowH;
if (isHeading) {
- headingRowH = rowH;
+ headingRowHeightD2 = rowH >> 1;
headings += rowH;
isHeading = false;
}
@@ -408,7 +407,10 @@ void PrintLayout::printTable()
pageIndexes.append(pageIndexes.last() + accH + headings);
table.resize(pageW, tableHeight);
- // attach a painter and render pages by using pageIndexes
+ /* attach a painter and render pages by using pageIndexes
+ * there is a weird QPicture dependency here; we need to offset a page
+ * by headingRowHeightD2, which is half the heading height. the same doesn't
+ * make sense if we are rendering the table widget directly to the printer-painter. */
QPainter painter(printer);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
@@ -417,17 +419,16 @@ void PrintLayout::printTable()
for (i = 0; i < total; i++) {
if (i > 0)
printer->newPage();
- QRegion region(0, pageIndexes.at(i) - 1,
- table.width(),
- pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
+ QRegion region(0, pageIndexes.at(i) + headingRowHeightD2 - 1,
+ table.width(),
+ pageIndexes.at(i + 1) - (pageIndexes.at(i) + headingRowHeightD2) + 1);
// vectorize the table first by using QPicture
QPicture pic;
QPainter picPainter;
picPainter.begin(&pic);
table.render(&picPainter, QPoint(0, 0), region);
picPainter.end();
- // for page# > 0, we need to offset the target point's Y by twice the heading row height
- painter.drawPicture(QPoint(0, (i > 0 ? -(headingRowH << 1) : 0)), pic);
+ painter.drawPicture(QPoint(0, headingRowHeightD2), pic);
progress++;
emit signalProgress(done + (progress * 10) / total);
}