-
Notifications
You must be signed in to change notification settings - Fork 62
/
expTree.py
70 lines (63 loc) · 2 KB
/
expTree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
#
# Expands selected tree and all sub trees in the tree view.
# if selected tree is already expanded this tree and all sub trees are collapsed
#
# Author: wmayer
import FreeCAD, FreeCADGui
from PySide import QtGui
#from PySide.QtGui import QTreeWidgetItemIterator
def toggleAllSel(tree, item, collapse):
if collapse == False:
tree.expandItem(item)
elif collapse == True:
tree.collapseItem(item)
for i in range(item.childCount()):
#print(item.child(i).text(0))
if 'Origin' not in item.child(i).text(0):
toggleAllSel(tree, item.child(i), collapse)
##
def toggle_Tree():
mw1 = FreeCADGui.getMainWindow()
treesSel = mw1.findChildren(QtGui.QTreeWidget)
for tree in treesSel:
items = tree.selectedItems()
for item in items:
if item.isExpanded() == True:
collapse = True
print ("collapsing")
else:
print ("expanding")
collapse = False
toggleAllSel(tree, item, collapse)
##
def collS_Tree():
# collapse selected
mw1 = FreeCADGui.getMainWindow()
treesSel = mw1.findChildren(QtGui.QTreeWidget)
for tree in treesSel:
items = tree.selectedItems()
for item in items:
if item.isExpanded() == True:
collapse = True
print ("collapsing")
tree.collapseItem(item)
#else:
# print ("expanding")
# collapse = False
##
def expS_Tree():
# expand selected
mw1 = FreeCADGui.getMainWindow()
treesSel = mw1.findChildren(QtGui.QTreeWidget)
for tree in treesSel:
items = tree.selectedItems()
for item in items:
if item.isExpanded() == False:
collapse = False
print ("expanding")
tree.expandItem(item)
#else:
# print ("expanding")
# collapse = False
##