Пример #1
0
    def buildListView(self, parent_item, parent_element, ag, reverse):
        this_item = None
        node = parent_element.lastChild().toElement() if reverse else parent_element.firstChild().toElement()
        while not node.isNull():
            if node.attribute("objectName") in("", "separator"):  # Pasamos de este
                node = node.previousSibling().toElement() if reverse else node.nextSibling().toElement()
                continue
            class_name = node.attribute("class")
            if class_name.startswith("QAction"):
                if node.attribute("visible") == "false":
                    node = node.previousSibling().toElement() if reverse else node.nextSibling().toElement()
                    continue

                if class_name == "QActionGroup":
                    group_name = node.attribute("objectName")
                    if (group_name not in ("pinebooActionGroup") and not group_name.endswith("Actions") and not group_name.startswith(("pinebooAg"))) or group_name.endswith("MoreActions"):

                        this_item = QTreeWidgetItem(parent_item)
                        this_item.setText(0, group_name)

                    else:
                        this_item = parent_item

                    self.buildListView(this_item, node, ag, reverse)
                    node = node.previousSibling().toElement() if reverse else node.nextSibling().toElement()
                    continue

                if node.attribute("objectName") not in("pinebooActionGroup", "pinebooActionGroup_actiongroup_name"):

                    action_name = node.attribute("objectName")

                    ac = ag.findChild(QtWidgets.QAction, action_name)
                    if ac is not None:

                        if action_name.endswith("actiongroup_name"):
                            #action_name = action_name.replace("_actiongroup_name", "")
                            this_item = parent_item
                        else:
                            this_item = QTreeWidgetItem(parent_item)

                        this_item.setIcon(0, ac.icon())  # Code el icono mal!!
                        if class_name == "QAction":
                            this_item.setText(1, action_name)
                        this_item.setText(0, node.attribute("text").replace("&", ""))
                    if node.attribute("enabled") == "false":
                        this_item.setEnabled(False)

                self.buildListView(this_item, node, ag, reverse)

            node = node.previousSibling().toElement() if reverse else node.nextSibling().toElement()