mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
Print: small adjustments to table printing
PrintLayout::printTable(): - hide the QTableView widget border using a stylesheet - add a guard to fix the last column extending post the page width due to rounding - use 1 extra pixel instead of 2 when grabbing the page region Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e727b899a6
commit
c79def40b1
1 changed files with 13 additions and 2 deletions
|
@ -266,6 +266,11 @@ void PrintLayout::printTable()
|
|||
// fit table to one page initially
|
||||
table.resize(scaledPageW, scaledPageH);
|
||||
|
||||
// don't show border
|
||||
table.setStyleSheet(
|
||||
"QTableView { border: none }"
|
||||
);
|
||||
|
||||
// create and fill a table model
|
||||
TablePrintModel model;
|
||||
struct dive *dive;
|
||||
|
@ -280,8 +285,14 @@ void PrintLayout::printTable()
|
|||
}
|
||||
table.setModel(&model); // set model to table
|
||||
// resize columns to percentages from page width
|
||||
int accW = 0;
|
||||
int cols = model.columns;
|
||||
int tableW = table.width();
|
||||
for (int i = 0; i < model.columns; i++) {
|
||||
int pw = qCeil((qreal)(tablePrintColumnWidths.at(i) * table.width()) / 100);
|
||||
int pw = qCeil((qreal)(tablePrintColumnWidths.at(i) * table.width()) / 100.0);
|
||||
accW += pw;
|
||||
if (i == cols - 1 && accW > tableW) /* adjust last column */
|
||||
pw -= accW - tableW;
|
||||
table.horizontalHeader()->resizeSection(i, pw);
|
||||
}
|
||||
// reset the model at this point
|
||||
|
@ -318,7 +329,7 @@ void PrintLayout::printTable()
|
|||
printer->newPage();
|
||||
QRegion region(0, pageIndexes.at(i) - 1,
|
||||
table.width(),
|
||||
pageIndexes.at(i + 1) - pageIndexes.at(i) + 2);
|
||||
pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
|
||||
table.render(&painter, QPoint(0, 0), region);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue