[PATCH] Print: fix truncated table in "Table print" mode

Dirk Hohndel dirk at hohndel.org
Thu Dec 5 08:03:51 UTC 2013


Close. I included it, but it doesn't fully FIX the issue.

Because if you have a few hundred dives, then the added 15+ entries may
overflow the last page... and you no longer create a new page for that,
so they run off the bottom of that page...

:-/

/D


On Thu, 2013-12-05 at 14:08 +0200, Lubomir I. Ivanov wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
> 
> The whole procedure here is quite confusing.
> Once we have our model populated, we need to estimate where
> to put page headers (each page has one) and to do that we
> store a list of indexes, where a page would begin (pageIndexes).
> 
> But since a row can end up being chopped at the end of a page
> we move it to a new page and this particular part was lacking
> compensation for the moved row's height, when storing the *last*
> pageIndex.
> 
> For N number of pages we are losing N - 1 dives, or such that
> were previously transferred on a new page.
> 
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
> 
> please test!
> ---
>  qt-ui/printlayout.cpp | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
> index 556bf13..004188c 100644
> --- a/qt-ui/printlayout.cpp
> +++ b/qt-ui/printlayout.cpp
> @@ -328,7 +328,7 @@ void PrintLayout::printTable()
>  	// a list of vertical offsets where pages begin and some helpers
>  	QList<unsigned int> pageIndexes;
>  	pageIndexes.append(0);
> -	int tableHeight = 0, rowH = 0, accH = 0;
> +	int tableHeight = 0, rowH = 0, accH = 0, headings = 0;
>  
>  	// process all rows
>  	progress = 0;
> @@ -339,6 +339,7 @@ void PrintLayout::printTable()
>  		if (accH > scaledPageH) { // push a new page index and add a heading
>  			pageIndexes.append(pageIndexes.last() + (accH - rowH));
>  			addTablePrintHeadingRow(&model, i);
> +			headings += rowH; // last row was moved to a new page; compensate!
>  			accH = 0;
>  			i--;
>  		}
> @@ -346,7 +347,7 @@ void PrintLayout::printTable()
>  		progress++;
>  		emit signalProgress(stage + (progress * stage) / total);
>  	}
> -	pageIndexes.append(pageIndexes.last() + accH);
> +	pageIndexes.append(pageIndexes.last() + accH + headings);
>  	// resize the whole widget so that it can be rendered
>  	table.resize(scaledPageW, tableHeight);
>  




More information about the subsurface mailing list