eric6/Graphics/UMLItem.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8207
d359172d11be
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
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()
197 @param option style options (QStyleOptionGraphicsItem) 199 @param option style options (QStyleOptionGraphicsItem)
198 @param widget optional reference to the widget painted on (QWidget) 200 @param widget optional reference to the widget painted on (QWidget)
199 """ 201 """
200 pen = self.pen() 202 pen = self.pen()
201 if ( 203 if (
202 (option.state & QStyle.State_Selected) == 204 (option.state & QStyle.StateFlag.State_Selected) ==
203 QStyle.State(QStyle.State_Selected) 205 QStyle.State(QStyle.StateFlag.State_Selected)
204 ): 206 ):
205 pen.setWidth(2) 207 pen.setWidth(2)
206 else: 208 else:
207 pen.setWidth(1) 209 pen.setWidth(1)
208 210

eric ide

mercurial