Graphics/ClassItem.py

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

eric ide

mercurial