@ -258,9 +258,20 @@ void UBSelectionFrame::remove()
updateRect ( ) ;
updateRect ( ) ;
}
}
static bool sortByZ ( UBGraphicsItemDelegate * A , UBGraphicsItemDelegate * B )
{
return ( A - > delegated ( ) - > data ( UBGraphicsItemData : : ItemOwnZValue ) . toReal ( )
< B - > delegated ( ) - > data ( UBGraphicsItemData : : ItemOwnZValue ) . toReal ( ) ) ;
}
void UBSelectionFrame : : duplicate ( )
void UBSelectionFrame : : duplicate ( )
{
{
UBApplication : : undoStack - > beginMacro ( UBSettings : : undoCommandTransactionName ) ;
UBApplication : : undoStack - > beginMacro ( UBSettings : : undoCommandTransactionName ) ;
// The mEnclosedtems list items are in order of selection. To avoid losing their
// relative zValues when duplicating, we re-order the list.
std : : sort ( mEnclosedtems . begin ( ) , mEnclosedtems . end ( ) , sortByZ ) ;
foreach ( UBGraphicsItemDelegate * d , mEnclosedtems ) {
foreach ( UBGraphicsItemDelegate * d , mEnclosedtems ) {
d - > duplicate ( ) ;
d - > duplicate ( ) ;
}
}