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
preferencesAboutTextFull
Craig Watson 8 years ago
parent d5746d2e8d
commit 214764dce3
  1. 2
      src/domain/UBGraphicsScene.cpp
  2. 11
      src/domain/UBSelectionFrame.cpp

@ -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();
}

Loading…
Cancel
Save