@@ -155,10 +155,20 @@ int QgsComposerTableV2::rowsVisible( const int frameIndex ) const
155155 }
156156 QRectF frameExtent = frame ( frameIndex )->extent ();
157157
158- // calculate header height
159- double headerHeight = 0 ;
158+ bool includeHeader = false ;
160159 if (( mHeaderMode == QgsComposerTableV2::FirstFrame && frameIndex < 1 )
161160 || ( mHeaderMode == QgsComposerTableV2::AllFrames ) )
161+ {
162+ includeHeader = true ;
163+ }
164+ return rowsVisible ( frameExtent.height (), includeHeader );
165+ }
166+
167+ int QgsComposerTableV2::rowsVisible ( const double frameHeight, const bool includeHeader ) const
168+ {
169+ // calculate header height
170+ double headerHeight = 0 ;
171+ if ( includeHeader )
162172 {
163173 // frame has a header
164174 headerHeight = 2 * ( mShowGrid ? mGridStrokeWidth : 0 ) + 2 * mCellMargin + QgsComposerUtils::fontAscentMM ( mHeaderFont );
@@ -170,7 +180,7 @@ int QgsComposerTableV2::rowsVisible( const int frameIndex ) const
170180 }
171181
172182 // remaining height available for content rows
173- double contentHeight = frameExtent. height () - headerHeight;
183+ double contentHeight = frameHeight - headerHeight;
174184
175185 // calculate number of visible rows
176186 double rowHeight = ( mShowGrid ? mGridStrokeWidth : 0 ) + 2 * mCellMargin + QgsComposerUtils::fontAscentMM ( mContentFont );
@@ -519,7 +529,8 @@ void QgsComposerTableV2::refreshAttributes()
519529
520530 // since contents have changed, we also need to recalculate the column widths
521531 // and size of table
522- adjustFrameToSize ();
532+ // gettablecontents does this!
533+ // adjustFrameToSize();
523534}
524535
525536bool QgsComposerTableV2::calculateMaxColumnWidths ()
@@ -602,6 +613,14 @@ double QgsComposerTableV2::totalHeight() const
602613 }
603614 }
604615
616+ if ( mResizeMode == QgsComposerMultiFrame::ExtendToNextPage )
617+ {
618+ heightOfLastFrame = mComposition ->paperHeight ();
619+ bool hasHeader = (( mHeaderMode == QgsComposerTableV2::FirstFrame && numberExistingFrames < 1 )
620+ || ( mHeaderMode == QgsComposerTableV2::AllFrames ) );
621+ rowsVisibleInLastFrame = rowsVisible ( heightOfLastFrame, hasHeader );
622+ }
623+
605624 // calculate how many rows left to show
606625 int remainingRows = mTableContents .length () - rowsAlreadyShown;
607626
@@ -685,9 +704,10 @@ void QgsComposerTableV2::drawVerticalGridLines( QPainter *painter, const QMap<in
685704void QgsComposerTableV2::adjustFrameToSize ()
686705{
687706 mTableSize = QSizeF ( totalWidth (), totalHeight () );
707+
708+ recalculateFrameSizes ();
709+
688710 // force recalculation of frame rects, so that they are set to the correct
689711 // fixed and minimum frame sizes
690712 recalculateFrameRects ();
691-
692- recalculateFrameSizes ();
693713}
0 commit comments