Skip to content

Commit

Permalink
[composer] Add method for overriding page break location in multi fra…
Browse files Browse the repository at this point in the history
…me items (sponsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent c37b848 commit 4885289
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
}
else
{
currentHeight = findNearbyPageBreak( currentY + currentHeight ) - currentY;
currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) );
}
currentItem->update();
Expand All @@ -103,7 +104,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
while (( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
{
//find out on which page the lower left point of the last frame is
int page = qFloor( (currentItem->pos().y() + currentItem->rect().height()) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1;
int page = qFloor(( currentItem->pos().y() + currentItem->rect().height() ) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1;

if ( mResizeMode == RepeatOnEveryPage )
{
Expand Down
7 changes: 7 additions & 0 deletions src/core/composer/qgscomposermultiframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject

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

/**Finds the optimal position to break a frame at.
* @param yPos maximum vertical position for break
* @returns the optimal breakable position which occurs in the multi frame close
* to and before the specified yPos
* Note: added in version 2.3*/
virtual double findNearbyPageBreak( double yPos ) { return yPos; }

void removeFrame( int i );

void update();
Expand Down

0 comments on commit 4885289

Please sign in to comment.