QmlDesigner: Do not use z-order for toFront/toBack

Task-number: QDS-370
Change-Id: I1cfff1b0f87e6dacb1f08c01a7b04d06eadb78e1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-08-19 15:47:30 +02:00
parent 33a4f8ab3c
commit 7393305b31

View File

@@ -198,9 +198,13 @@ void toFront(const SelectionContext &selectionState)
try { try {
QmlItemNode node = selectionState.firstSelectedModelNode(); QmlItemNode node = selectionState.firstSelectedModelNode();
if (node.isValid()) { if (node.isValid()) {
signed int maximumZ = getMaxZValue(siblingsForNode(node)); ModelNode modelNode = selectionState.currentSingleSelectedNode();
maximumZ++; NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
node.setVariantProperty("z", maximumZ); const int index = parentProperty.indexOf(modelNode);
const int lastIndex = parentProperty.count() - 1;
if (index != lastIndex)
parentProperty.slide(index, lastIndex);
} }
} catch (const RewritingException &e) { //better save then sorry } catch (const RewritingException &e) { //better save then sorry
e.showException(); e.showException();
@@ -215,9 +219,12 @@ void toBack(const SelectionContext &selectionState)
try { try {
QmlItemNode node = selectionState.firstSelectedModelNode(); QmlItemNode node = selectionState.firstSelectedModelNode();
if (node.isValid()) { if (node.isValid()) {
signed int minimumZ = getMinZValue(siblingsForNode(node)); ModelNode modelNode = selectionState.currentSingleSelectedNode();
minimumZ--; NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
node.setVariantProperty("z", minimumZ); const int index = parentProperty.indexOf(modelNode);
if (index != 0)
parentProperty.slide(index, 0);
} }
} catch (const RewritingException &e) { //better save then sorry } catch (const RewritingException &e) { //better save then sorry