gui: support moving item inside plain group
This commit is contained in:
parent
383163d163
commit
f7041b1625
31
gui.py
31
gui.py
|
@ -838,16 +838,13 @@ class AsmCmdUp(AsmCmdBase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getSelection(cls):
|
def getSelection(cls):
|
||||||
from .assembly import isTypeOf, Assembly, AsmGroup
|
from .assembly import AsmPlainGroup
|
||||||
sels = FreeCADGui.Selection.getSelectionEx('',False)
|
sels = FreeCADGui.Selection.getSelection()
|
||||||
if len(sels)!=1 or len(sels[0].SubElementNames)!=1:
|
if len(sels)==1:
|
||||||
return
|
obj = sels[0]
|
||||||
ret= sels[0].Object.resolve(sels[0].SubElementNames[0])
|
parent = AsmPlainGroup.getParentGroup(obj)
|
||||||
obj,parent = ret[0],ret[1]
|
if parent and len(parent.Group)>1:
|
||||||
if isTypeOf(parent,Assembly) or not isTypeOf(parent,AsmGroup) or \
|
return obj,parent
|
||||||
len(parent.Group) <= 1:
|
|
||||||
return
|
|
||||||
return (obj,parent,sels[0].Object,sels[0].SubElementNames[0])
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def checkActive(cls):
|
def checkActive(cls):
|
||||||
|
@ -858,7 +855,7 @@ class AsmCmdUp(AsmCmdBase):
|
||||||
ret = cls.getSelection()
|
ret = cls.getSelection()
|
||||||
if not ret:
|
if not ret:
|
||||||
return
|
return
|
||||||
obj,parent,topParent,subname = ret
|
obj,parent = ret
|
||||||
children = parent.Group
|
children = parent.Group
|
||||||
i = children.index(obj)
|
i = children.index(obj)
|
||||||
j = i+step
|
j = i+step
|
||||||
|
@ -869,16 +866,10 @@ class AsmCmdUp(AsmCmdBase):
|
||||||
logger.debug('move {}:{} -> {}:{}',
|
logger.debug('move {}:{} -> {}:{}',
|
||||||
i,objName(obj),j,objName(children[j]))
|
i,objName(obj),j,objName(children[j]))
|
||||||
FreeCAD.setActiveTransaction(cls._menuText)
|
FreeCAD.setActiveTransaction(cls._menuText)
|
||||||
readonly = 'Immutable' in parent.getPropertyStatus('Group')
|
children[i],children[j] = children[j],obj
|
||||||
if readonly:
|
from .assembly import editGroup
|
||||||
parent.setPropertyStatus('Group','-Immutable')
|
editGroup(parent,children)
|
||||||
parent.Group = {i:children[j],j:obj}
|
|
||||||
if readonly:
|
|
||||||
parent.setPropertyStatus('Group','Immutable')
|
|
||||||
FreeCAD.closeActiveTransaction();
|
FreeCAD.closeActiveTransaction();
|
||||||
# The tree view may deselect the item because of claimChildren changes,
|
|
||||||
# so we restore the selection here
|
|
||||||
FreeCADGui.Selection.addSelection(topParent,subname)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def onSelectionChange(cls,hasSelection):
|
def onSelectionChange(cls,hasSelection):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user