Graphics/ClassItem.py

changeset 2992
dbdf27746da5
parent 2302
f29e9405c851
child 3057
10516539f238
child 3160
209a07d7e401
equal deleted inserted replaced
2991:226481ff40d1 2992:dbdf27746da5
76 rounded=False, noAttrs=False, parent=None, scene=None): 76 rounded=False, noAttrs=False, parent=None, scene=None):
77 """ 77 """
78 Constructor 78 Constructor
79 79
80 @param model class model containing the class data (ClassModel) 80 @param model class model containing the class data (ClassModel)
81 @param external flag indicating a class defined outside our scope (boolean) 81 @param external flag indicating a class defined outside our scope
82 (boolean)
82 @param x x-coordinate (integer) 83 @param x x-coordinate (integer)
83 @param y y-coordinate (integer) 84 @param y y-coordinate (integer)
84 @keyparam rounded flag indicating a rounded corner (boolean) 85 @keyparam rounded flag indicating a rounded corner (boolean)
85 @keyparam noAttrs flag indicating, that no attributes should be shown (boolean) 86 @keyparam noAttrs flag indicating, that no attributes should be shown
87 (boolean)
86 @keyparam parent reference to the parent object (QGraphicsItem) 88 @keyparam parent reference to the parent object (QGraphicsItem)
87 @keyparam scene reference to the scene object (QGraphicsScene) 89 @keyparam scene reference to the scene object (QGraphicsScene)
88 """ 90 """
89 UMLItem.__init__(self, model, x, y, rounded, parent) 91 UMLItem.__init__(self, model, x, y, rounded, parent)
90 92
180 @param painter reference to the painter object (QPainter) 182 @param painter reference to the painter object (QPainter)
181 @param option style options (QStyleOptionGraphicsItem) 183 @param option style options (QStyleOptionGraphicsItem)
182 @param widget optional reference to the widget painted on (QWidget) 184 @param widget optional reference to the widget painted on (QWidget)
183 """ 185 """
184 pen = self.pen() 186 pen = self.pen()
185 if (option.state & QStyle.State_Selected) == QStyle.State(QStyle.State_Selected): 187 if (option.state & QStyle.State_Selected) == \
188 QStyle.State(QStyle.State_Selected):
186 pen.setWidth(2) 189 pen.setWidth(2)
187 else: 190 else:
188 pen.setWidth(1) 191 pen.setWidth(1)
189 192
190 painter.setPen(pen) 193 painter.setPen(pen)
199 painter.drawRect(offsetX, offsetY, w, h) 202 painter.drawRect(offsetX, offsetY, w, h)
200 y = self.margin + self.header.boundingRect().height() 203 y = self.margin + self.header.boundingRect().height()
201 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y) 204 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y)
202 if self.attrs: 205 if self.attrs:
203 y += self.margin + self.attrs.boundingRect().height() 206 y += self.margin + self.attrs.boundingRect().height()
204 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y) 207 painter.drawLine(offsetX, offsetY + y,
208 offsetX + w - 1, offsetY + y)
205 209
206 self.adjustAssociations() 210 self.adjustAssociations()
207 211
208 def isExternal(self): 212 def isExternal(self):
209 """ 213 """
216 def buildItemDataString(self): 220 def buildItemDataString(self):
217 """ 221 """
218 Public method to build a string to persist the specific item data. 222 Public method to build a string to persist the specific item data.
219 223
220 This string must start with ", " and should be built like 224 This string must start with ", " and should be built like
221 "attribute=value" with pairs separated by ", ". value must not contain ", " 225 "attribute=value" with pairs separated by ", ". value must not
222 or newlines. 226 contain ", " or newlines.
223 227
224 @return persistence data (string) 228 @return persistence data (string)
225 """ 229 """
226 entries = [ 230 entries = [
227 "is_external={0}".format(self.external), 231 "is_external={0}".format(self.external),

eric ide

mercurial