|
@ -104,7 +104,29 @@ class TNLData(object): |
|
|
out.children.append(outitem) |
|
|
out.children.append(outitem) |
|
|
return out |
|
|
return out |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def filter_treenode(cls, treenode, predicate): |
|
|
|
|
|
tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) |
|
|
|
|
|
# Teď vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všecny nalezené TNLData |
|
|
|
|
|
result = cls(None) |
|
|
|
|
|
for idx, tnl in enumerate(tnll): |
|
|
|
|
|
result.children.append(tnl) |
|
|
|
|
|
tnl.parent = result |
|
|
|
|
|
tnl.index = idx |
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _filter_treenode_recursive(cls, treenode, predicate): |
|
|
|
|
|
if predicate(treenode): |
|
|
|
|
|
return [cls.from_treenode(treenode)] |
|
|
|
|
|
else: |
|
|
|
|
|
found = [] |
|
|
|
|
|
for tn in all_children(treenode): |
|
|
|
|
|
result = cls.filter_treenode(tn, predicate) |
|
|
|
|
|
# Result by v tuhle chvíli měl být seznam TNLDat odpovídající treenodům, jež matchnuly predikát. |
|
|
|
|
|
for tnl in result: |
|
|
|
|
|
found.append(tnl) |
|
|
|
|
|
return found |
|
|
|
|
|
|
|
|
class TreeNodeView(generic.DetailView): |
|
|
class TreeNodeView(generic.DetailView): |
|
|
model = s.TreeNode |
|
|
model = s.TreeNode |
|
|