diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-10-03 17:50:41 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-10-03 09:39:16 -0700 |
commit | c79def40b106fbefaa64b0a9f769b6bcb4b9efd5 (patch) | |
tree | 0883dc2b907dcd16d5a58df5f25b25f9e0dd499c /qt-ui | |
parent | e727b899a633a6c7eaf075dcf7380aadd6f85b7f (diff) | |
download | subsurface-c79def40b106fbefaa64b0a9f769b6bcb4b9efd5.tar.gz |
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>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/printlayout.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 4f741d64e..8224c916b 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -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); } } |