def expand_to_node(self, node):
"""
Expand tree until given node and select it
"""
if isinstance(node, str):
idxlist = self.model.match(self.model.index(0, 0), Qt.DisplayRole, node, 1, Qt.MatchExactly|Qt.MatchRecursive)
node = self.model.data(idxlist[0], Qt.UserRole)
path = node.get_path()
for node in path:
# FIXME: this would be the correct way if it would work
#idxlist = self.model.match(self.model.index(0, 0), Qt.UserRole, QVariantnode, 2, Qt.MatchExactly|Qt.MatchRecursive)
try:
text = node.get_display_name().Text
except UaError as ex:
return
idxlist = self.model.match(self.model.index(0, 0), Qt.DisplayRole, text, 1, Qt.MatchExactly|Qt.MatchRecursive)
if idxlist:
idx = idxlist[0]
self.view.setExpanded(idx, True)
self.view.setCurrentIndex(idx)
self.view.activated.emit(idx)
评论列表
文章目录