eric6/Graphics/ModuleItem.py

changeset 7529
2b8a0d8ba12a
parent 7360
9190402e4505
child 7780
41420f82c0ac
equal deleted inserted replaced
7528:0345f54d3959 7529:2b8a0d8ba12a
50 """ 50 """
51 Class implementing a module item. 51 Class implementing a module item.
52 """ 52 """
53 ItemType = "module" 53 ItemType = "module"
54 54
55 def __init__(self, model=None, x=0, y=0, rounded=False, 55 def __init__(self, model=None, x=0, y=0, rounded=False, colors=None,
56 parent=None, scene=None): 56 parent=None, scene=None):
57 """ 57 """
58 Constructor 58 Constructor
59 59
60 @param model module model containing the module data (ModuleModel) 60 @param model module model containing the module data
61 @param x x-coordinate (integer) 61 @type ModuleModel
62 @param y y-coordinate (integer) 62 @param x x-coordinate
63 @keyparam rounded flag indicating a rounded corner (boolean) 63 @type int
64 @keyparam parent reference to the parent object (QGraphicsItem) 64 @param y y-coordinate
65 @keyparam scene reference to the scene object (QGraphicsScene) 65 @type int
66 """ 66 @param rounded flag indicating a rounded corner
67 UMLItem.__init__(self, model, x, y, rounded, parent) 67 @type bool
68 @param colors tuple containing the foreground and background colors
69 @type tuple of (QColor, QColor)
70 @param parent reference to the parent object
71 @type QGraphicsItem
72 @param scene reference to the scene object
73 @type QGraphicsScene
74 """
75 UMLItem.__init__(self, model, x, y, rounded, colors, parent)
68 76
69 scene.addItem(self) 77 scene.addItem(self)
70 78
71 if self.model: 79 if self.model:
72 self.__createTexts() 80 self.__createTexts()
85 classes = self.model.getClasses() 93 classes = self.model.getClasses()
86 94
87 x = self.margin + self.rect().x() 95 x = self.margin + self.rect().x()
88 y = self.margin + self.rect().y() 96 y = self.margin + self.rect().y()
89 self.header = QGraphicsSimpleTextItem(self) 97 self.header = QGraphicsSimpleTextItem(self)
98 self.header.setBrush(self._colors[0])
90 self.header.setFont(boldFont) 99 self.header.setFont(boldFont)
91 self.header.setText(self.model.getName()) 100 self.header.setText(self.model.getName())
92 self.header.setPos(x, y) 101 self.header.setPos(x, y)
93 y += self.header.boundingRect().height() + self.margin 102 y += self.header.boundingRect().height() + self.margin
94 if classes: 103 if classes:
95 txt = "\n".join(classes) 104 txt = "\n".join(classes)
96 else: 105 else:
97 txt = " " 106 txt = " "
98 self.classes = QGraphicsSimpleTextItem(self) 107 self.classes = QGraphicsSimpleTextItem(self)
108 self.classes.setBrush(self._colors[0])
99 self.classes.setFont(self.font) 109 self.classes.setFont(self.font)
100 self.classes.setText(txt) 110 self.classes.setText(txt)
101 self.classes.setPos(x, y) 111 self.classes.setPos(x, y)
102 112
103 def __calculateSize(self): 113 def __calculateSize(self):

eric ide

mercurial