61 """ |
61 """ |
62 super(UMLItem, self).__init__(parent) |
62 super(UMLItem, self).__init__(parent) |
63 self.model = model |
63 self.model = model |
64 |
64 |
65 if colors is None: |
65 if colors is None: |
66 self._colors = (QColor(Qt.black), QColor(Qt.white)) |
66 self._colors = (QColor(Qt.GlobalColor.black), |
|
67 QColor(Qt.GlobalColor.white)) |
67 else: |
68 else: |
68 self._colors = colors |
69 self._colors = colors |
69 self.setPen(QPen(self._colors[0])) |
70 self.setPen(QPen(self._colors[0])) |
70 |
71 |
71 self.font = Preferences.getGraphics("Font") |
72 self.font = Preferences.getGraphics("Font") |
76 |
77 |
77 self.setRect(x, y, 60, 30) |
78 self.setRect(x, y, 60, 30) |
78 |
79 |
79 if rounded: |
80 if rounded: |
80 p = self.pen() |
81 p = self.pen() |
81 p.setCapStyle(Qt.RoundCap) |
82 p.setCapStyle(Qt.PenCapStyle.RoundCap) |
82 p.setJoinStyle(Qt.RoundJoin) |
83 p.setJoinStyle(Qt.PenJoinStyle.RoundJoin) |
83 |
84 |
84 self.setFlag(QGraphicsItem.ItemIsMovable, True) |
85 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsMovable, True) |
85 self.setFlag(QGraphicsItem.ItemIsSelectable, True) |
86 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, True) |
86 try: |
87 try: |
87 self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) |
88 self.setFlag( |
|
89 QGraphicsItem.GraphicsItemFlag.ItemSendsGeometryChanges, True) |
88 except AttributeError: |
90 except AttributeError: |
89 # only available for Qt 4.6.0 and newer |
91 # only available for Qt 4.6.0 and newer |
90 pass |
92 pass |
91 |
93 |
92 def getName(self): |
94 def getName(self): |
173 |
175 |
174 @param change the item's change (QGraphicsItem.GraphicsItemChange) |
176 @param change the item's change (QGraphicsItem.GraphicsItemChange) |
175 @param value the value of the change |
177 @param value the value of the change |
176 @return adjusted values |
178 @return adjusted values |
177 """ |
179 """ |
178 if change == QGraphicsItem.ItemPositionChange: |
180 if change == QGraphicsItem.GraphicsItemChange.ItemPositionChange: |
179 # 1. remember to adjust associations |
181 # 1. remember to adjust associations |
180 self.shouldAdjustAssociations = True |
182 self.shouldAdjustAssociations = True |
181 |
183 |
182 # 2. ensure the new position is inside the scene |
184 # 2. ensure the new position is inside the scene |
183 rect = self.scene().sceneRect() |
185 rect = self.scene().sceneRect() |