Beispiel #1
0
    def mousePressEvent(self, e):
        if self.supress:
            return

        self.last_press = self.itemAt(e.scenePos(), QTransform())

        if self.selection:
            if (e.button()==qt.LeftButton and not self.itemAt(e.scenePos(), QTransform())) or e.button()==qt.RightButton:
                old_selection = self.selection
                self.selection = set()
                for it in old_selection:
                    try:
                        it.selected = False
                    except AttributeError:
                        pass
        if not self.itemAt(e.scenePos(), QTransform()):
            if e.button()==qt.LeftButton:
                if e.modifiers()&qt.ShiftModifier:
                    self.selection_path_item = QGraphicsPathItem()
                    self.selection_path = path = QPainterPath()
                    self.selection_path_item.setPen(QPen(Color.selection, 0, qt.DashLine))
                    path.moveTo(e.scenePos())
                    self.selection_path_item.setPath(path)
                    self.addItem(self.selection_path_item)
            if e.button()==qt.LeftButton or (self.use_rightclick and e.button()==qt.RightButton):
                if not e.modifiers()&qt.ShiftModifier:
                    self.place(e.scenePos(), Cell.full if (e.button()==qt.LeftButton)^self.swap_buttons else Cell.empty)
        else:
            QGraphicsScene.mousePressEvent(self, e)