Ejemplo n.º 1
0
 def removeEdge(self, edge):
     """
     Remove the given edge from the current node.
     :type edge: AbstractEdge
     """
     super().removeEdge(edge)
     identify(self)
Ejemplo n.º 2
0
 def addEdge(self, edge):
     """
     Add the given edge to the current node.
     :type edge: AbstractEdge
     """
     super().addEdge(edge)
     identify(self)
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()