Skip to content

Commit 4885289

Browse files
committedApr 28, 2014
[composer] Add method for overriding page break location in multi frame items (sponsored by City of Uster, Switzerland)
1 parent c37b848 commit 4885289

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/core/composer/qgscomposermultiframe.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
9191
}
9292
else
9393
{
94+
currentHeight = findNearbyPageBreak( currentY + currentHeight ) - currentY;
9495
currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) );
9596
}
9697
currentItem->update();
@@ -103,7 +104,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
103104
while (( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
104105
{
105106
//find out on which page the lower left point of the last frame is
106-
int page = qFloor( (currentItem->pos().y() + currentItem->rect().height()) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1;
107+
int page = qFloor(( currentItem->pos().y() + currentItem->rect().height() ) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1;
107108

108109
if ( mResizeMode == RepeatOnEveryPage )
109110
{

‎src/core/composer/qgscomposermultiframe.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject
4848

4949
virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
5050

51+
/**Finds the optimal position to break a frame at.
52+
* @param yPos maximum vertical position for break
53+
* @returns the optimal breakable position which occurs in the multi frame close
54+
* to and before the specified yPos
55+
* Note: added in version 2.3*/
56+
virtual double findNearbyPageBreak( double yPos ) { return yPos; }
57+
5158
void removeFrame( int i );
5259

5360
void update();

0 commit comments

Comments
 (0)
Please sign in to comment.