recursive generator for tree leaves
This commit is contained in:
@@ -330,11 +330,17 @@ class MyTreeWidget(QTreeWidget):
|
|||||||
self.parent.update_history_tab()
|
self.parent.update_history_tab()
|
||||||
self.parent.update_completions()
|
self.parent.update_completions()
|
||||||
|
|
||||||
def filter(self, p, column):
|
def get_leaves(self, root):
|
||||||
root = self.invisibleRootItem()
|
|
||||||
child_count = root.childCount()
|
child_count = root.childCount()
|
||||||
|
if child_count == 0:
|
||||||
|
yield root
|
||||||
for i in range(child_count):
|
for i in range(child_count):
|
||||||
item = root.child(i)
|
item = root.child(i)
|
||||||
|
for x in self.get_leaves(item):
|
||||||
|
yield x
|
||||||
|
|
||||||
|
def filter(self, p, column):
|
||||||
|
for item in self.get_leaves(self.invisibleRootItem()):
|
||||||
item.setHidden(unicode(item.text(column)).lower().find(p) == -1)
|
item.setHidden(unicode(item.text(column)).lower().find(p) == -1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user