Skip to content

Commit

Permalink
[composer] Fix duplicate frames when multi frame is set to Repeat on …
Browse files Browse the repository at this point in the history
…Every Page (sponsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent dafae53 commit c37b848
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
mYLineEdit->blockSignals( true );
mWidthLineEdit->blockSignals( true );
mHeightLineEdit->blockSignals( true );
mUpperLeftCheckBox->blockSignals( true );
mUpperMiddleCheckBox->blockSignals( true );
mUpperRightCheckBox->blockSignals( true );
mMiddleLeftCheckBox->blockSignals( true );
mMiddleCheckBox->blockSignals( true );
mMiddleRightCheckBox->blockSignals( true );
mLowerLeftCheckBox->blockSignals( true );
mLowerMiddleCheckBox->blockSignals( true );
mLowerRightCheckBox->blockSignals( true );


if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
Expand Down Expand Up @@ -334,6 +343,15 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
mYLineEdit->blockSignals( false );
mWidthLineEdit->blockSignals( false );
mHeightLineEdit->blockSignals( false );
mUpperLeftCheckBox->blockSignals( false );
mUpperMiddleCheckBox->blockSignals( false );
mUpperRightCheckBox->blockSignals( false );
mMiddleLeftCheckBox->blockSignals( false );
mMiddleCheckBox->blockSignals( false );
mMiddleRightCheckBox->blockSignals( false );
mLowerLeftCheckBox->blockSignals( false );
mLowerMiddleCheckBox->blockSignals( false );
mLowerRightCheckBox->blockSignals( false );
}

void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
Expand Down
15 changes: 9 additions & 6 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "qgscomposermultiframe.h"
#include "qgscomposerframe.h"
#include "qgscomposition.h"
#include <QtCore>

QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ):
mComposition( c ),
Expand Down Expand Up @@ -102,19 +103,21 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
while (( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
{
//find out on which page the lower left point of the last frame is
int page = currentItem->pos().y() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
int page = qFloor( (currentItem->pos().y() + currentItem->rect().height()) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1;

if ( mResizeMode == RepeatOnEveryPage )
{
if ( page > mComposition->numPages() - 2 )
if ( page >= mComposition->numPages() )
{
break;
}
}
else
{
if ( mComposition->numPages() < ( page + 2 ) )
//add an extra page if required
if ( mComposition->numPages() < ( page + 1 ) )
{
mComposition->setNumPages( page + 2 );
mComposition->setNumPages( page + 1 );
}
}

Expand All @@ -128,10 +131,10 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
frameHeight = ( currentY + mComposition->paperHeight() ) > totalHeight ? totalHeight - currentY : mComposition->paperHeight();
}

double newFrameY = ( page + 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
double newFrameY = page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
if ( mResizeMode == RepeatUntilFinished || mResizeMode == RepeatOnEveryPage )
{
newFrameY += currentItem->pos().y() - page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
newFrameY += currentItem->pos().y() - ( page - 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
}
QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->pos().x(),
newFrameY,
Expand Down

0 comments on commit c37b848

Please sign in to comment.