Skip to content
Permalink
Browse files

[composer] Fix duplicate frames when multi frame is set to Repeat on …

…Every Page (sponsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent dafae53 commit c37b848305f19746922d8bdfd1c255a5c2207e4f
Showing with 27 additions and 6 deletions.
  1. +18 −0 src/app/composer/qgscomposeritemwidget.cpp
  2. +9 −6 src/core/composer/qgscomposermultiframe.cpp
@@ -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 )
@@ -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()
@@ -16,6 +16,7 @@
#include "qgscomposermultiframe.h"
#include "qgscomposerframe.h"
#include "qgscomposition.h"
#include <QtCore>

QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ):
mComposition( c ),
@@ -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 );
}
}

@@ -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,

0 comments on commit c37b848

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