@@ -220,6 +220,7 @@ QRectF QgsComposition::compositionBounds() const
220
220
221
221
void QgsComposition::setPaperSize ( double width, double height )
222
222
{
223
+ // update item positions
223
224
QList<QGraphicsItem *> itemList = items ();
224
225
QList<QGraphicsItem *>::iterator itemIt = itemList.begin ();
225
226
for ( ; itemIt != itemList.end (); ++itemIt )
@@ -230,6 +231,28 @@ void QgsComposition::setPaperSize( double width, double height )
230
231
composerItem->updatePagePos ( width, height );
231
232
}
232
233
}
234
+ // update guide positions and size
235
+ QList< QGraphicsLineItem* >* guides = snapLines ();
236
+ QList< QGraphicsLineItem* >::iterator guideIt = guides->begin ();
237
+ double totalHeight = ( height + spaceBetweenPages () ) * ( numPages () - 1 ) + height;
238
+ for ( ; guideIt != guides->end (); ++guideIt )
239
+ {
240
+ QLineF line = ( *guideIt )->line ();
241
+ if ( line.dx () == 0 )
242
+ {
243
+ // vertical line, change height of line
244
+ ( *guideIt )->setLine ( line.x1 (), 0 , line.x1 (), totalHeight );
245
+ }
246
+ else
247
+ {
248
+ // horizontal line
249
+ // move to new vertical position and change width of line
250
+ QPointF curPagePos = positionOnPage ( line.p1 () );
251
+ int curPage = pageNumberForPoint ( line.p1 () ) - 1 ;
252
+ double newY = curPage * ( height + spaceBetweenPages () ) + curPagePos.y ();
253
+ ( *guideIt )->setLine ( 0 , newY, width, newY );
254
+ }
255
+ }
233
256
234
257
mPageWidth = width;
235
258
mPageHeight = height;
@@ -275,6 +298,20 @@ void QgsComposition::setNumPages( int pages )
275
298
}
276
299
}
277
300
301
+ // update vertical guide height
302
+ QList< QGraphicsLineItem* >* guides = snapLines ();
303
+ QList< QGraphicsLineItem* >::iterator guideIt = guides->begin ();
304
+ double totalHeight = ( mPageHeight + spaceBetweenPages () ) * ( pages - 1 ) + mPageHeight ;
305
+ for ( ; guideIt != guides->end (); ++guideIt )
306
+ {
307
+ QLineF line = ( *guideIt )->line ();
308
+ if ( line.dx () == 0 )
309
+ {
310
+ // vertical line, change height of line
311
+ ( *guideIt )->setLine ( line.x1 (), 0 , line.x1 (), totalHeight );
312
+ }
313
+ }
314
+
278
315
// update the corresponding variable
279
316
QgsExpression::setSpecialColumn ( " $numpages" , QVariant (( int )numPages () ) );
280
317
0 commit comments