Example #1
0
    def mousePressEvent(self, event: QGraphicsSceneMouseEvent):
        """Implementation.

    A left-click places a tile on a grid space, while a right-click removes a
    tile.
    """

        editor = self._editor
        pos = event.buttonDownScenePos(event.button())
        if editor.validGridPos(pos, scene=True):
            self.lastTilePos = editor.sceneToGrid(pos)
            if event.button() is Qt.LeftButton:
                return self.handleLeftButton(pos)
            elif event.button() is Qt.RightButton:
                return self.handleRightButton(pos)
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent):
     if event.button() == Qt.LeftButton and \
             event.modifiers() & Qt.ControlModifier:
         tabIndex = self.tabWidget.currentIndex()
         tabName = self.tabWidget.tabText(tabIndex)
         rowIndex = self.tabWidget.getCurrentTableModel().rowCount(
             QModelIndex())
         label = self.comboBox.currentText()
         box = QRectF(event.buttonDownScenePos(Qt.LeftButton), QSizeF(1, 1))
         color = self.tabWidget.color_map(tabIndex)[label]
         rect = self.addBox(tabIndex, tabName, rowIndex, self.page, label,
                            box, color)
         rect.handleSelected = 4
         self.signalHandler.boxCreated.emit(rect)
     super().mousePressEvent(event)
Example #3
0
    def mousePressEvent(self, event: QGraphicsSceneMouseEvent):
        mousePos = QPointF(
            event.buttonDownScenePos(Qt.LeftButton).x(),
            event.buttonDownScenePos(Qt.LeftButton).y())

        itemList = list(self.items(mousePos))
        super(GraphicsScene, self).mousePressEvent(event)

        if event.button() == Qt.LeftButton:
            if len(self.nodeList) <= 2:
                if self.focusItem():
                    self.nodeList.append((self.focusItem(), time()))

        if not self.focusItem():
            self.nodeList.clear()

        if len(itemList) > 0:
            self.m_Item = itemList[0]
            self.itemLock.emit(self.m_Item)
        if self.m_Item is not None and event.button() == Qt.LeftButton:
            self.m_oldPos = self.m_Item.pos()
Example #4
0
    def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
        if not self.focusItem():
            self.nodeList.clear()
        if event.buttons() and Qt.LeftButton:
            mousePos = QPointF(
                event.buttonDownScenePos(Qt.LeftButton).x(),
                event.buttonDownScenePos(Qt.LeftButton).y())
            itemList = list(self.items(mousePos))
            if len(itemList) > 0:
                self.m_Item = itemList[0]
                self.itemLock.emit(self.m_Item)
        if len(self.nodeList) > 0:
            self.itemNode.emit(self.nodeList)
        if not self.another:
            if len(self.nodeList) > 1:
                self.nodeList = self.nodeList[1:]
        self.isHasItem.emit(len(self.items()))

        if len(self.nodeList) > 2:
            self.nodeList.clear()

        super(GraphicsScene, self).mouseMoveEvent(event)