100 boldFont = QFont(self.font) |
100 boldFont = QFont(self.font) |
101 boldFont.setBold(True) |
101 boldFont.setBold(True) |
102 |
102 |
103 modules = self.model.getModules() |
103 modules = self.model.getModules() |
104 |
104 |
105 x = self.margin + self.rect().x() |
105 x = self.margin + int(self.rect().x()) |
106 y = self.margin + self.rect().y() |
106 y = self.margin + int(self.rect().y()) |
107 self.header = QGraphicsSimpleTextItem(self) |
107 self.header = QGraphicsSimpleTextItem(self) |
108 self.header.setBrush(self._colors[0]) |
108 self.header.setBrush(self._colors[0]) |
109 self.header.setFont(boldFont) |
109 self.header.setFont(boldFont) |
110 self.header.setText(self.model.getName()) |
110 self.header.setText(self.model.getName()) |
111 self.header.setPos(x, y) |
111 self.header.setPos(x, y) |
112 y += self.header.boundingRect().height() + self.margin |
112 y += int(self.header.boundingRect().height()) + self.margin |
113 |
113 |
114 if not self.noModules: |
114 if not self.noModules: |
115 if modules: |
115 if modules: |
116 txt = "\n".join(modules) |
116 txt = "\n".join(modules) |
117 else: |
117 else: |
129 Private method to calculate the size of the package widget. |
129 Private method to calculate the size of the package widget. |
130 """ |
130 """ |
131 if self.model is None: |
131 if self.model is None: |
132 return |
132 return |
133 |
133 |
134 width = self.header.boundingRect().width() |
134 width = int(self.header.boundingRect().width()) |
135 height = self.header.boundingRect().height() |
135 height = int(self.header.boundingRect().height()) |
136 if self.modules: |
136 if self.modules: |
137 width = max(width, self.modules.boundingRect().width()) |
137 width = max(width, |
138 height += self.modules.boundingRect().height() |
138 int(self.modules.boundingRect().width())) |
|
139 height += int(self.modules.boundingRect().height()) |
139 latchW = width / 3.0 |
140 latchW = width / 3.0 |
140 latchH = min(15.0, latchW) |
141 latchH = min(15.0, latchW) |
141 self.setSize(width + 2 * self.margin, |
142 self.setSize(width + 2 * self.margin, |
142 height + latchH + 2 * self.margin) |
143 height + latchH + 2 * self.margin) |
143 |
144 |
144 x = self.margin + self.rect().x() |
145 x = self.margin + int(self.rect().x()) |
145 y = self.margin + self.rect().y() + latchH |
146 y = self.margin + int(self.rect().y()) + latchH |
146 self.header.setPos(x, y) |
147 self.header.setPos(x, y) |
147 y += self.header.boundingRect().height() + self.margin |
148 y += int(self.header.boundingRect().height()) + self.margin |
148 if self.modules: |
149 if self.modules: |
149 self.modules.setPos(x, y) |
150 self.modules.setPos(x, y) |
150 |
151 |
151 def setModel(self, model): |
152 def setModel(self, model): |
152 """ |
153 """ |
182 ): |
183 ): |
183 pen.setWidth(2) |
184 pen.setWidth(2) |
184 else: |
185 else: |
185 pen.setWidth(1) |
186 pen.setWidth(1) |
186 |
187 |
187 offsetX = self.rect().x() |
188 offsetX = int(self.rect().x()) |
188 offsetY = self.rect().y() |
189 offsetY = int(self.rect().y()) |
189 w = self.rect().width() |
190 w = int(self.rect().width()) |
190 latchW = w / 3.0 |
191 latchW = w / 3.0 |
191 latchH = min(15.0, latchW) |
192 latchH = min(15.0, latchW) |
192 h = self.rect().height() - latchH + 1 |
193 h = int(self.rect().height() - latchH + 1) |
193 |
194 |
194 painter.setPen(pen) |
195 painter.setPen(pen) |
195 painter.setBrush(self.brush()) |
196 painter.setBrush(self.brush()) |
196 painter.setFont(self.font) |
197 painter.setFont(self.font) |
197 |
198 |
198 painter.drawRect(offsetX, offsetY, latchW, latchH) |
199 painter.drawRect(offsetX, offsetY, int(latchW), int(latchH)) |
199 painter.drawRect(offsetX, offsetY + latchH, w, h) |
200 painter.drawRect(offsetX, offsetY + int(latchH), w, h) |
200 y = self.margin + self.header.boundingRect().height() + latchH |
201 y = int(self.margin + self.header.boundingRect().height() + latchH) |
201 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y) |
202 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y) |
202 |
203 |
203 self.adjustAssociations() |
204 self.adjustAssociations() |
204 |
205 |
205 def parseItemDataString(self, version, data): |
206 def parseItemDataString(self, version, data): |