Skip to content
Permalink
Browse files

[composer] Manually removing a frame from a multi frame forces the mu…

…lti frame to UseExistingFrames mode, otherwise the frame may not actually be removed. This changes makes the behaviour of multi frames a bit more predictable (sponsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent 86304b9 commit e9b253d8bc38bbf04bfa82e1d5d4aed966ddb8ff
Showing with 25 additions and 2 deletions.
  1. +23 −2 src/core/composer/qgscomposermultiframe.cpp
  2. +2 −0 src/core/composer/qgscomposermultiframe.h
@@ -17,13 +17,20 @@
#include "qgscomposerframe.h"
#include "qgscomposition.h"

QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ): mComposition( c ), mResizeMode( UseExistingFrames ), mCreateUndoCommands( createUndoCommands )
QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ):
mComposition( c ),
mResizeMode( UseExistingFrames ),
mCreateUndoCommands( createUndoCommands ),
mIsRecalculatingSize( false )
{
mComposition->addMultiFrame( this );
connect( mComposition, SIGNAL( nPagesChanged() ), this, SLOT( handlePageChange() ) );
}

QgsComposerMultiFrame::QgsComposerMultiFrame(): mComposition( 0 ), mResizeMode( UseExistingFrames )
QgsComposerMultiFrame::QgsComposerMultiFrame():
mComposition( 0 ),
mResizeMode( UseExistingFrames ),
mIsRecalculatingSize( false )
{
}

@@ -159,6 +166,13 @@ void QgsComposerMultiFrame::handleFrameRemoval( QgsComposerItem* item )
mFrameItems.removeAt( index );
if ( mFrameItems.size() > 0 )
{
if ( resizeMode() != QgsComposerMultiFrame::RepeatOnEveryPage && !mIsRecalculatingSize )
{
//removing a frame forces the multi frame to UseExistingFrames resize mode
//otherwise the frame may not actually be removed, leading to confusing ui behaviour
mResizeMode = QgsComposerMultiFrame::UseExistingFrames;
emit changed();
}
recalculateFrameSizes();
}
}
@@ -206,10 +220,17 @@ void QgsComposerMultiFrame::handlePageChange()

void QgsComposerMultiFrame::removeFrame( int i )
{
if ( i >= mFrameItems.count() )
{
return;
}

QgsComposerFrame* frameItem = mFrameItems[i];
if ( mComposition )
{
mIsRecalculatingSize = true;
mComposition->removeComposerItem( frameItem );
mIsRecalculatingSize = false;
}
mFrameItems.removeAt( i );
}
@@ -92,6 +92,8 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject
private:
QgsComposerMultiFrame(); //forbidden

bool mIsRecalculatingSize;

signals:
void changed();
};

0 comments on commit e9b253d

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