Example #1
0
 def filterItems(item: QTreeWidgetItem) -> bool:
     op_class: type = item.data(1, Qt.UserRole)
     keep: bool = bool(item.parent())
     if keep and issubclass(op_class, GraphOperation):
         keep &= op_class.minInputNumber() == op_class.maxInputNumber() == 1 \
                 and op_class.minOutputNumber() == 1
     else:
         keep &= item.isHidden()
     return keep
Example #2
0
 def item_clicked(item: QtWidgets.QTreeWidgetItem):
     if item.parent() is None:
         return
     value = self.redis.get(item.text(0))
     value = value.decode()
     text = json.dumps(json.loads(value), ensure_ascii=False, indent=4)
     text = text.replace("  ", "&nbsp;").replace("\n", "<br/>").replace(":", "<font color=red>:</font>")
     text = re.sub(r'"(.*?)(?<!\\)"', r'<font color=green>"\g<1>"</font>', text)
     self.label.setHtml(text)
Example #3
0
    def get_path_for_item(self, item: QtWidgets.QTreeWidgetItem) -> str:
        """Returns the absolute os path for given item."""
        path = []
        path.append(item.text(0))

        parent = item.parent()

        while parent is not None:
            path.insert(0, parent.text(0))
            parent = parent.parent()

        return os.path.join(self.root_path, *path)
Example #4
0
 def _result_item_pressed(self, item: QTreeWidgetItem, column: int):
     if item.parent() is not self.result_tree:
         prx_index = self.fakom_tree.model().mapFromSource(item.data(0, Qt.UserRole))
         if prx_index.isValid():
             self.fakom_tree.scrollTo(prx_index, QAbstractItemView.PositionAtCenter)