CustomQGraphicsTextItem(const QString& text, BasicBlockWidget* parent)
: QGraphicsTextItem(text, parent), parent(parent) {}
void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
+
+ void adjustSize();
private:
void addComment(int row, bool global);
menu.exec(event->screenPos());
}
+void CustomQGraphicsTextItem::adjustSize() {
+ int width = 1000;
+ setTextWidth(width);
+ int height = boundingRect().height();
+ while (height == boundingRect().height()) {
+ setTextWidth(width -= 10);
+ }
+ width += 10;
+ if (width < 250) width = 250;
+ setTextWidth(width);
+}
+
BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
Mainwindow * mainwindow)
- : width(270), height(45), name(name)
+ : width(200), height(45), name(name)
, _table(NULL)
, block(block), mainwindow(mainwindow)
, logger(log4cxx::Logger::getLogger("gui.BasicBlockWidget." + name.toStdString())) {
c.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, i.fragment().length());
c.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor);
c.insertText(event->new_name.c_str());
+
+ QGraphicsTextItem* item = _widget.get();
+ ((CustomQGraphicsTextItem*)item)->adjustSize();
}
}
}
}
cursor.removeSelectedText();
cursor.insertHtml(formatComments(&*inst_it));
+ QGraphicsTextItem* item = _widget.get();
+ ((CustomQGraphicsTextItem*)item)->adjustSize();
}
}
bytestring += hexdigits[byte & 0xF];
bytestring += ' ';
}
- _table->cellAt(row, 0).firstCursorPosition().insertText(bytestring);
+ _table->cellAt(row, 0).firstCursorPosition().insertHtml("<nobr>" + bytestring + "</nobr>");
QString line = inst.getText().c_str();
line = line.replace('\t', ' ').toHtmlEscaped();
}
line = "<a href=\"" + href + "\">" + line + "</a>";
}
- _table->cellAt(row, 1).firstCursorPosition().insertHtml(line);
+ _table->cellAt(row, 1).firstCursorPosition().insertHtml("<nobr>" + line + "</nobr>");
_table->cellAt(row, 2).firstCursorPosition().insertHtml(formatComments(&inst));
}
+ QGraphicsTextItem* item = _widget.get();
+ ((CustomQGraphicsTextItem*)item)->adjustSize();
}
QString BasicBlockWidget::formatComments(Instruction* inst) {
void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,
QWidget*) {
- _widget->adjustSize();
width = 10 + _widget->boundingRect().width();
height = 25 + _widget->boundingRect().height();
if (width < 250) width = 250;