227 |
227 |
228 width = self.header.boundingRect().width() |
228 width = self.header.boundingRect().width() |
229 height = self.header.boundingRect().height() |
229 height = self.header.boundingRect().height() |
230 if self.classAttributes: |
230 if self.classAttributes: |
231 width = max(width, self.classAttributes.boundingRect().width()) |
231 width = max(width, self.classAttributes.boundingRect().width()) |
232 height += self.classAttributes.boundingRect().height() + self.margin |
232 height += ( |
|
233 self.classAttributes.boundingRect().height() + self.margin |
|
234 ) |
233 if self.attrs: |
235 if self.attrs: |
234 width = max(width, self.attrs.boundingRect().width()) |
236 width = max(width, self.attrs.boundingRect().width()) |
235 height = height + self.attrs.boundingRect().height() + self.margin |
237 height = height + self.attrs.boundingRect().height() + self.margin |
236 if self.meths: |
238 if self.meths: |
237 width = max(width, self.meths.boundingRect().width()) |
239 width = max(width, self.meths.boundingRect().width()) |
241 |
243 |
242 def setModel(self, model): |
244 def setModel(self, model): |
243 """ |
245 """ |
244 Public method to set the class model. |
246 Public method to set the class model. |
245 |
247 |
246 @param model class model containing the class data (ClassModel) |
248 @param model class model containing the class data |
|
249 @type ClassModel |
247 """ |
250 """ |
248 self.scene().removeItem(self.header) |
251 self.scene().removeItem(self.header) |
249 self.header = None |
252 self.header = None |
250 if self.classAttributes: |
253 if self.classAttributes: |
251 self.scene().removeItem(self.classAttributes) |
254 self.scene().removeItem(self.classAttributes) |
262 |
265 |
263 def paint(self, painter, option, widget=None): |
266 def paint(self, painter, option, widget=None): |
264 """ |
267 """ |
265 Public method to paint the item in local coordinates. |
268 Public method to paint the item in local coordinates. |
266 |
269 |
267 @param painter reference to the painter object (QPainter) |
270 @param painter reference to the painter object |
268 @param option style options (QStyleOptionGraphicsItem) |
271 @type QPainter |
269 @param widget optional reference to the widget painted on (QWidget) |
272 @param option style options |
|
273 @type QStyleOptionGraphicsItem |
|
274 @param widget optional reference to the widget painted on |
|
275 @type QWidget |
270 """ |
276 """ |
271 pen = self.pen() |
277 pen = self.pen() |
272 if ( |
278 if ( |
273 (option.state & QStyle.StateFlag.State_Selected) == |
279 (option.state & QStyle.StateFlag.State_Selected) == |
274 QStyle.State(QStyle.StateFlag.State_Selected) |
280 QStyle.State(QStyle.StateFlag.State_Selected) |
314 |
321 |
315 This string must start with ", " and should be built like |
322 This string must start with ", " and should be built like |
316 "attribute=value" with pairs separated by ", ". value must not |
323 "attribute=value" with pairs separated by ", ". value must not |
317 contain ", " or newlines. |
324 contain ", " or newlines. |
318 |
325 |
319 @return persistence data (string) |
326 @return persistence data |
|
327 @rtype str |
320 """ |
328 """ |
321 entries = [ |
329 entries = [ |
322 "is_external={0}".format(self.external), |
330 "is_external={0}".format(self.external), |
323 "no_attributes={0}".format(self.noAttrs), |
331 "no_attributes={0}".format(self.noAttrs), |
324 "name={0}".format(self.model.getName()), |
332 "name={0}".format(self.model.getName()), |
340 |
348 |
341 def parseItemDataString(self, version, data): |
349 def parseItemDataString(self, version, data): |
342 """ |
350 """ |
343 Public method to parse the given persistence data. |
351 Public method to parse the given persistence data. |
344 |
352 |
345 @param version version of the data (string) |
353 @param version version of the data |
346 @param data persisted data to be parsed (string) |
354 @type str |
347 @return flag indicating success (boolean) |
355 @param data persisted data to be parsed |
|
356 @type str |
|
357 @return flag indicating success |
|
358 @rtype bool |
348 """ |
359 """ |
349 parts = data.split(", ") |
360 parts = data.split(", ") |
350 if len(parts) < 3: |
361 if len(parts) < 3: |
351 return False |
362 return False |
352 |
363 |