mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
50b4617cd4
commit
0a53449e76
1 changed files with 10 additions and 1 deletions
|
@ -377,6 +377,7 @@ void PrintLayout::printTable()
|
||||||
const int passes[] = { 70, 10 };
|
const int passes[] = { 70, 10 };
|
||||||
int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings;
|
int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings;
|
||||||
bool isHeading = false;
|
bool isHeading = false;
|
||||||
|
int headingRowH;
|
||||||
|
|
||||||
for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) {
|
for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) {
|
||||||
progress = headings = accH = 0;
|
progress = headings = accH = 0;
|
||||||
|
@ -385,6 +386,7 @@ void PrintLayout::printTable()
|
||||||
rowH = table.rowHeight(i);
|
rowH = table.rowHeight(i);
|
||||||
accH += rowH;
|
accH += rowH;
|
||||||
if (isHeading) {
|
if (isHeading) {
|
||||||
|
headingRowH = rowH;
|
||||||
headings += rowH;
|
headings += rowH;
|
||||||
isHeading = false;
|
isHeading = false;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +420,14 @@ void PrintLayout::printTable()
|
||||||
QRegion region(0, pageIndexes.at(i) - 1,
|
QRegion region(0, pageIndexes.at(i) - 1,
|
||||||
table.width(),
|
table.width(),
|
||||||
pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
|
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++;
|
progress++;
|
||||||
emit signalProgress(done + (progress * 10) / total);
|
emit signalProgress(done + (progress * 10) / total);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue