Skip to content
Permalink
Browse files

Add new composer multiframe resize methods ExtendToNextPage and Repea…

…tUntilFinished
  • Loading branch information
mhugent committed Aug 17, 2012
1 parent ed98805 commit a37611e087dccb869cd0cf4e20ad53a904666891
@@ -13,6 +13,8 @@ QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposer
blockSignals( true );
mResizeModeComboBox->addItem( tr( "Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames );
mResizeModeComboBox->addItem( tr( "Extend to next page" ), QgsComposerMultiFrame::ExtendToNextPage );
mResizeModeComboBox->addItem( tr( "Repeat on every page" ), QgsComposerMultiFrame::RepeatOnEveryPage );
mResizeModeComboBox->addItem( tr( "Repeat until finished" ), QgsComposerMultiFrame::RepeatUntilFinished );
blockSignals( false );
setGuiElementValues();

@@ -63,7 +63,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
{
if ( currentY >= totalHeight )
{
if ( mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode
if ( mResizeMode == RepeatUntilFinished || mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode
{
for ( int j = mFrameItems.size(); j > i; --j )
{
@@ -81,7 +81,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
}

//at end of frames but there is still content left. Add other pages if ResizeMode ==
if ( mResizeMode == ExtendToNextPage )
if ( mResizeMode == RepeatUntilFinished || mResizeMode == ExtendToNextPage )
{
while ( currentY < totalHeight )
{
@@ -94,11 +94,20 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
mComposition->setNumPages( page + 2 );
}

//copy last frame
QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->transform().dx(), currentItem->transform().dy() + mComposition->paperHeight() + mComposition->spaceBetweenPages(),
currentItem->rect().width(), currentItem->rect().height() );
double frameHeight = 0;
if ( mResizeMode == RepeatUntilFinished )
{
frameHeight = currentItem->rect().height();
}
else //mResizeMode == ExtendToNextPage
{
frameHeight = ( currentY + mComposition->paperHeight() ) > totalHeight ? totalHeight - currentY : mComposition->paperHeight();
}
QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->transform().dx(),
( mComposition->numPages() - 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ),
currentItem->rect().width(), frameHeight );
newFrame->setContentSection( QRectF( 0, currentY, newFrame->rect().width(), newFrame->rect().height() ) );
currentY += newFrame->rect().height();
currentY += frameHeight;
currentItem = newFrame;
addFrame( newFrame, false );
}
@@ -36,7 +36,9 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject
enum ResizeMode
{
UseExistingFrames = 0,
ExtendToNextPage //duplicates last frame to next page to fit the total size
ExtendToNextPage, //uses the next page(s) until the content has been printed
RepeatOnEveryPage, //repeats the same frame on every page
RepeatUntilFinished //duplicates last frame to next page to fit the total size
};

QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );

0 comments on commit a37611e

Please sign in to comment.
You can’t perform that action at this time.