(self, fromIndex, toIndex, modifiers)
| 25 | """There is no need to override '__init__' it has the same signature as the implementation in GraphicsView.""" |
| 26 | |
| 27 | def addConstraint(self, fromIndex, toIndex, modifiers): |
| 28 | print("MyGraphicsView::addConstraint()") |
| 29 | if self.isReadOnly(): |
| 30 | return |
| 31 | |
| 32 | cmodel = self.constraintModel() |
| 33 | constraintType = None |
| 34 | if modifiers & Qt.ShiftModifier: |
| 35 | constraintType = ConstraintModel.TypeHard |
| 36 | else: |
| 37 | constraintType = ConstraintModel.TypeSoft |
| 38 | |
| 39 | c = ConstraintModel(fromIndex, toIndex, constraintType) |
| 40 | c.setData(ConstraintModel.ValidConstraintPen, |
| 41 | QPen(QColor(Qt.green), 3, Qt.DashLine)) |
| 42 | c.setData(ConstraintModel.InvalidConstraintPen, |
| 43 | QPen(QColor(Qt.blue), 3, Qt.DashLine)) |
| 44 | if cmodel.hasConstraint(c): |
| 45 | cmodel.removeConstraint(c) |
| 46 | else: |
| 47 | cmodel.addConstraint(c) |
| 48 | |
| 49 | |
| 50 | # pylint: disable=too-few-public-methods |
nothing calls this directly
no test coverage detected