示例#1
0
 def removeEdge(self, edge):
     """
     Remove the given edge from the current node.
     :type edge: AbstractEdge
     """
     super().removeEdge(edge)
     identify(self)
示例#2
0
 def addEdge(self, edge):
     """
     Add the given edge to the current node.
     :type edge: AbstractEdge
     """
     super().addEdge(edge)
     identify(self)
示例#3
0
    def undo(self):
        """undo the command"""
        # If the command is executed in a "refactor" command we won't have
        # any meta except for the first node in the refactored collection
        # so we don't have to remove nor add predicates from the meta index.
        meta = self.scene.meta.metaFor(self.node.item, self.data['redo'])
        if meta:
            self.scene.meta.remove(self.node.item, self.data['redo'])

        self.scene.index.remove(self.node)
        self.node.setText(self.data['undo'])
        self.scene.index.add(self.node)

        if meta:
            meta.predicate = self.data['undo']
            self.scene.meta.add(self.node.item, self.data['undo'], meta)

        if self.node.isItem(Item.IndividualNode):
            f1 = lambda x: x.isItem(Item.InputEdge) and x.source is self.node
            f2 = lambda x: x.isItem(Item.EnumerationNode)
            for node in {
                    n
                    for n in
                [e.other(self.node) for e in self.node.edges if f1(e)] if f2(n)
            }:
                identify(node)

        self.scene.sgnUpdated.emit()
示例#4
0
    def addEdge(self, edge):
        """
        Add the given edge to the current node.
        :type edge: AbstractEdge
        """
        super().addEdge(edge)

        if edge.isItem(Item.InputEdge) and edge.target is self:
            self.inputs.append(edge.id)
            edge.updateEdge()

        identify(self)
示例#5
0
    def removeEdge(self, edge):
        """
        Remove the given edge from the current node.
        :type edge: AbstractEdge
        """
        super().removeEdge(edge)

        self.inputs.remove(edge.id)
        scene = self.scene()
        for i in self.inputs:
            try:
                edge = scene.edge(i)
                edge.updateEdge()
            except KeyError:
                pass

        identify(self)
示例#6
0
    def undo(self):
        """undo the command"""
        # If the command is executed in a "refactor" command we won't have
        # any meta except for the first node in the refactored collection
        # so we don't have to remove nor add predicates from the meta index.
        meta = self.scene.meta.metaFor(self.node.item, self.data['redo'])
        if meta:
            self.scene.meta.remove(self.node.item, self.data['redo'])

        self.scene.index.remove(self.node)
        self.node.setText(self.data['undo'])
        self.scene.index.add(self.node)

        if meta:
            meta.predicate = self.data['undo']
            self.scene.meta.add(self.node.item, self.data['undo'], meta)

        if self.node.isItem(Item.IndividualNode):
            f1 = lambda x: x.isItem(Item.InputEdge) and x.source is self.node
            f2 = lambda x: x.isItem(Item.EnumerationNode)
            for node in {n for n in [e.other(self.node) for e in self.node.edges if f1(e)] if f2(n)}:
                identify(node)

        self.scene.sgnUpdated.emit()