Commit 214764dc authored by Craig Watson's avatar Craig Watson

zValue tweaks

- Sort by Z before duplicating a selection (so that relative Z's are
kept)
- in UBZLayerController, iterate only through UBGraphicsScene's fast
access items, not QGraphicsScene::items
parent d5746d2e
......@@ -302,7 +302,7 @@ void UBZLayerController::shiftStoredZValue(QGraphicsItem *item, qreal zValue)
*/
bool UBZLayerController::zLevelAvailable(qreal z)
{
foreach(QGraphicsItem* it, mScene->items()) {
foreach(QGraphicsItem* it, dynamic_cast<UBGraphicsScene*>(mScene)->getFastAccessItems()) {
if (it->zValue() == z)
return false;
}
......
......@@ -258,9 +258,20 @@ void UBSelectionFrame::remove()
updateRect();
}
static bool sortByZ(UBGraphicsItemDelegate* A, UBGraphicsItemDelegate* B)
{
return (A->delegated()->data(UBGraphicsItemData::ItemOwnZValue).toReal()
< B->delegated()->data(UBGraphicsItemData::ItemOwnZValue).toReal() );
}
void UBSelectionFrame::duplicate()
{
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) {
d->duplicate();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment