diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2014-08-05 20:45:53 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-05 12:49:16 -0700 |
commit | 81125d190a216d5718e44a984aef62fc3d7d07fe (patch) | |
tree | e23c5aa19382ceb00e36803a325d3653ff4ef1b2 /qt-ui/printlayout.cpp | |
parent | 4583cd8e09944e61aa59baa58e74abee0af0d268 (diff) | |
download | subsurface-81125d190a216d5718e44a984aef62fc3d7d07fe.tar.gz |
Print: add a safe guard for row heights in the table print
If a row height is more than the available height on a page
(minus the height of a heading row) we have to skip this row (dive).
The current profile print simply does not support that and it does
not make much sense. For that to happen either the page will have
to be tiny or the user must have entered a very long text for "buddy",
"dive master", "location" or there must be some sort of a
very-large-font-while-printing type of a problem.
Technically, rows spanning on multiple pages is doable, but probably
not worth the effort.
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 | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index e7fba9bfb..8fdee858f 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -384,7 +384,7 @@ 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, headingRowHeightD2; + int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings, headingRowHeightD2, headingRowHeight; bool isHeading = false; for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) { @@ -392,9 +392,14 @@ void PrintLayout::printTable() total = model.rows - lastAccIndex; for (i = lastAccIndex; i < model.rows; i++) { rowH = table.rowHeight(i); + if (i == 0) { // first row is always a heading. it's height is constant. + headingRowHeight = rowH; + headingRowHeightD2 = rowH / 2; + } + if (rowH > pageH - headingRowHeight) // skip huge rows. we don't support row spanning on multiple pages. + continue; accH += rowH; if (isHeading) { - headingRowHeightD2 = rowH >> 1; headings += rowH; isHeading = false; } |