Esempio n. 1
0
    def mouseMoveEvent(self, e: QMouseEvent):
        if self.__action == Action.DRAG:
            dx = e.x() - self.__origin.x()
            dy = e.y() - self.__origin.y()
            self.set_pos(self.x() + dx, self.y() + dy)
        elif self.__action == Action.RESIZE:
            self.set_size(e.x(), e.y())
        elif self.__action == Action.CONNECTING and self.__line is not None:
            p = QPoint(e.x() + self.x(), e.y() + self.y())

            n = self.parent().get_node(p)
            if n is not None and n.compatible(self.__line.n1):
                self.__line.status(True)
            else:
                self.__line.status(False)

            self.__line.update(p)

        else:
            n = self.node(e.pos())
            if self.__label is None and n is not None:
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif self.__label is not None and self.__label.node() is not n and n is not None:
                self.parent().delete_label(self.__label)
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif n is None:
                self.parent().delete_label(self.__label)
                self.__label = None
Esempio n. 2
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__drag:
         w = self.width() - e.x()
         if w <= 11:
             w = 11
         if w >= 450:
             w = 450
         self.setFixedWidth(w)
     elif e.x() <= 12 and 9 <= e.y() <= 31:
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.setCursor(Qt.ArrowCursor)
Esempio n. 3
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__action == Action.DRAG:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.set_pos(self.x() + dx, self.y() + dy)
     elif self.__action == Action.RESIZE:
         self.set_size(e.x(), e.y())
     else:
         if self._resizable and self.__corner_path.translated(self.width(), self.height()).contains(e.pos()):
             self.setCursor(Qt.SizeFDiagCursor)
         else:
             self.setCursor(Qt.ArrowCursor)
Esempio n. 4
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__action == Action.DRAG:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.set_pos(self.x() + dx, self.y() + dy)
     elif self.__action == Action.RESIZE:
         self.set_size(e.x(), e.y())
     else:
         if self._resizable and self.__corner_path.translated(
                 self.width(), self.height()).contains(e.pos()):
             self.setCursor(Qt.SizeFDiagCursor)
         else:
             self.setCursor(Qt.ArrowCursor)
Esempio n. 5
0
    def mousePressEvent(self, e: QMouseEvent):
        self.parent().select(self)
        n = self.node(e.pos())

        if n is not None:
            self.__line = self.__create_line(n)
            self.__action = Action.CONNECTING
            if self.__label is not None and self.__label.node() is not n:
                self.parent().delete_label(self.__label)
                self.__label = None
            return

        if self.__label is not None:
            self.parent().delete_label(self.__label)
            self.__label = None

        if self._resizable:
            if abs(e.x() - self.width()) < 8 + Block.padding \
                    and abs(e.y() - self.height()) < 8 + Block.padding \
                    and self._check_action(Action.RESIZE):
                self.__origin = e.pos()
                self.__action = Action.RESIZE
                return
        if self._check_action(Action.DRAG):
            self.__origin = e.pos()
            self.__action = Action.DRAG
Esempio n. 6
0
 def mousePressEvent(self, event: QMouseEvent):
     progress = event.x() / self.width()
     value = int(progress * self.maximum())
     self.setValue(value)
Esempio n. 7
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__moving:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.__origin = e.pos()
         self.translate(dx, dy)
Esempio n. 8
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__moving:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.__origin = e.pos()
         self.translate(dx, dy)
Esempio n. 9
0
 def mousePressEvent(self, e: QMouseEvent):
     if e.x() <= 12 and 9 <= e.y() <= 31 and e.button() == Qt.LeftButton:
         self.__drag = True
         self.repaint()
     else:
         self.__drag = False