]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.cxx
cceb2ffd26a064d57464b0b4b0df9d93bfe95abf
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.cxx
1 #include "BasicBlockWidget.hxx"
2
3 BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block)
4 : width(270), height(45)
5 , name(name), block(block)
6 , _proxy(this) {
7 next[0] = NULL; next[1] = NULL;
8 _proxy.setWidget(&_widget);
9 _widget.setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse);
10 _widget.setStyleSheet("QLabel { background-color : #ddddff; }");
11 _proxy.setPos(5, 20);
12
13 if (width < 270) width = 270;
14 }
15
16 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
17 QString line, const QString& href) {
18 QString bytestring;
19
20 for (size_t i(0); i < num_bytes; ++i) {
21 const char * hexdigits = "0123456789ABCDEF";
22 bytestring += hexdigits[(bytes[i] >> 4) & 0xF];
23 bytestring += hexdigits[bytes[i] & 0xF];
24 bytestring += ' ';
25 }
26
27 QString old_text = _widget.text();
28 if (old_text == "") {
29 old_text = "<table>";
30 }
31
32 line = line.toHtmlEscaped();
33 if (href != "") {
34 line = "<a href=\"" + href + "\">" + line + "</a>";
35 }
36
37 QString new_text =
38 old_text.remove("</table>") +
39 "<tr><td>" + bytestring +
40 "</td><td>" + line +
41 "</td><td>" + "" +
42 "</td></tr></table>";
43
44 _widget.setText(new_text);
45 width = 12 + _widget.sizeHint().width();
46 height = 25 + _widget.sizeHint().height();
47
48 if (width < 250) width = 250;
49 _widget.resize(width - 12, height - 25);
50 }