|
17 | 17 | #include "qgscomposerframe.h" |
18 | 18 | #include "qgscomposition.h" |
19 | 19 |
|
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 ) |
21 | 25 | { |
22 | 26 | mComposition->addMultiFrame( this ); |
23 | 27 | connect( mComposition, SIGNAL( nPagesChanged() ), this, SLOT( handlePageChange() ) ); |
24 | 28 | } |
25 | 29 |
|
26 | | -QgsComposerMultiFrame::QgsComposerMultiFrame(): mComposition( 0 ), mResizeMode( UseExistingFrames ) |
| 30 | +QgsComposerMultiFrame::QgsComposerMultiFrame(): |
| 31 | + mComposition( 0 ), |
| 32 | + mResizeMode( UseExistingFrames ), |
| 33 | + mIsRecalculatingSize( false ) |
27 | 34 | { |
28 | 35 | } |
29 | 36 |
|
@@ -159,6 +166,13 @@ void QgsComposerMultiFrame::handleFrameRemoval( QgsComposerItem* item ) |
159 | 166 | mFrameItems.removeAt( index ); |
160 | 167 | if ( mFrameItems.size() > 0 ) |
161 | 168 | { |
| 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 | + } |
162 | 176 | recalculateFrameSizes(); |
163 | 177 | } |
164 | 178 | } |
@@ -206,10 +220,17 @@ void QgsComposerMultiFrame::handlePageChange() |
206 | 220 |
|
207 | 221 | void QgsComposerMultiFrame::removeFrame( int i ) |
208 | 222 | { |
| 223 | + if ( i >= mFrameItems.count() ) |
| 224 | + { |
| 225 | + return; |
| 226 | + } |
| 227 | + |
209 | 228 | QgsComposerFrame* frameItem = mFrameItems[i]; |
210 | 229 | if ( mComposition ) |
211 | 230 | { |
| 231 | + mIsRecalculatingSize = true; |
212 | 232 | mComposition->removeComposerItem( frameItem ); |
| 233 | + mIsRecalculatingSize = false; |
213 | 234 | } |
214 | 235 | mFrameItems.removeAt( i ); |
215 | 236 | } |
|
0 commit comments