QGraphicsTextItem* item = _widget.get();
item->setDocument(document);
item->adjustSize();
+ updateSize();
}
QString BasicBlockWidget::formatComments(Instruction* inst) {
return (comments.empty() ? "" : ";; ") + comments.join("<br />").trimmed();
}
-void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,
- QWidget*) {
+void BasicBlockWidget::updateSize() {
+ prepareGeometryChange();
width = 10 + _widget->boundingRect().width();
height = 25 + _widget->boundingRect().height();
if (width < 250) width = 250;
+}
+
+void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,
+ QWidget*) {
+ updateSize();
painter->fillRect(0, 0, width, height, currentColor);
painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));