diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2014-07-25 03:50:45 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-24 21:10:44 -0700 |
commit | 0a53449e7620adf75322eafc0a3c870ccefd6fef (patch) | |
tree | 87b5f790711220d0d556891963772c2539a70533 /qt-ui/printlayout.cpp | |
parent | 50b4617cd4ba31ea9495f8538a5a4c070cdfbced (diff) | |
download | subsurface-0a53449e7620adf75322eafc0a3c870ccefd6fef.tar.gz |
PrintLayout: vectorize the table print
Use QPicture to do that.
QPainter::drawPicture() requires offsetting the target QPoint's
Y value by two times the headingRow height.
This can be improved the hardcodding the offset when the
'pageIndexes' are calculated, but is a bit complicated.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/printlayout.cpp')
-rw-r--r-- | qt-ui/printlayout.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index d6c27b597..277f48054 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -377,6 +377,7 @@ void PrintLayout::printTable() const int passes[] = { 70, 10 }; int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings; bool isHeading = false; + int headingRowH; for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) { progress = headings = accH = 0; @@ -385,6 +386,7 @@ void PrintLayout::printTable() rowH = table.rowHeight(i); accH += rowH; if (isHeading) { + headingRowH = rowH; headings += rowH; isHeading = false; } @@ -418,7 +420,14 @@ void PrintLayout::printTable() QRegion region(0, pageIndexes.at(i) - 1, table.width(), pageIndexes.at(i + 1) - pageIndexes.at(i) + 1); - table.render(&painter, QPoint(0, 0), region); + // 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); progress++; emit signalProgress(done + (progress * 10) / total); } |