Skip to content

Commit e9b253d

Browse files
committedApr 28, 2014
[composer] Manually removing a frame from a multi frame forces the multi 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)
1 parent 86304b9 commit e9b253d

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎src/core/composer/qgscomposermultiframe.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@
1717
#include "qgscomposerframe.h"
1818
#include "qgscomposition.h"
1919

20-
QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ): mComposition( c ), mResizeMode( UseExistingFrames ), mCreateUndoCommands( createUndoCommands )
20+
QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ):
21+
mComposition( c ),
22+
mResizeMode( UseExistingFrames ),
23+
mCreateUndoCommands( createUndoCommands ),
24+
mIsRecalculatingSize( false )
2125
{
2226
mComposition->addMultiFrame( this );
2327
connect( mComposition, SIGNAL( nPagesChanged() ), this, SLOT( handlePageChange() ) );
2428
}
2529

26-
QgsComposerMultiFrame::QgsComposerMultiFrame(): mComposition( 0 ), mResizeMode( UseExistingFrames )
30+
QgsComposerMultiFrame::QgsComposerMultiFrame():
31+
mComposition( 0 ),
32+
mResizeMode( UseExistingFrames ),
33+
mIsRecalculatingSize( false )
2734
{
2835
}
2936

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

207221
void QgsComposerMultiFrame::removeFrame( int i )
208222
{
223+
if ( i >= mFrameItems.count() )
224+
{
225+
return;
226+
}
227+
209228
QgsComposerFrame* frameItem = mFrameItems[i];
210229
if ( mComposition )
211230
{
231+
mIsRecalculatingSize = true;
212232
mComposition->removeComposerItem( frameItem );
233+
mIsRecalculatingSize = false;
213234
}
214235
mFrameItems.removeAt( i );
215236
}

‎src/core/composer/qgscomposermultiframe.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject
9292
private:
9393
QgsComposerMultiFrame(); //forbidden
9494

95+
bool mIsRecalculatingSize;
96+
9597
signals:
9698
void changed();
9799
};

0 commit comments

Comments
 (0)
Please sign in to comment.