]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.cxx
Name Blocks according to start *and* end address
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.cxx
1 #include "BasicBlockWidget.hxx"
2
3 BasicBlockWidget::BasicBlockWidget(const QString& name)
4 : x(-5), y(-20)
5 , dx(270), dy(45)
6 , name(name) {
7 _widget.setGridStyle(Qt::NoPen);
8 _widget.setMinimumHeight(_widget.rowHeight(0) + 10);
9 _widget.setMaximumHeight(20);
10 _widget.resizeColumnToContents(0);
11 _widget.resizeColumnToContents(1);
12 _widget.resizeColumnToContents(2);
13 _widget.updateGeometry();
14 _widget.setMaximumWidth(260);
15 _widget.setColumnCount(3);
16 _widget.verticalHeader()->hide();
17 _widget.horizontalHeader()->hide();
18 dx = _widget.rowHeight(0) + 20;
19 if (dx < 270) dx = 270;
20 }
21
22 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
23 const QString& line) {
24 size_t current_row = _widget.rowCount();
25 int column_width;
26
27 QString bytestring;
28
29 for (size_t i(0); i < num_bytes; ++i) {
30 const char * hexdigits = "0123456789ABCDEF";
31 bytestring += hexdigits[(bytes[i] >> 4) & 0xF];
32 bytestring += hexdigits[bytes[i] & 0xF];
33 bytestring += ' ';
34 }
35
36 _widget.setRowCount(current_row + 1);
37
38 _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring));
39 _widget.setItem(current_row, 1, new QTableWidgetItem(line));
40 _widget.setItem(current_row, 2, new QTableWidgetItem(""));
41 _widget.updateGeometry();
42
43 _widget.resizeColumnToContents(0);
44 _widget.resizeColumnToContents(1);
45 _widget.resizeColumnToContents(2);
46
47 _widget.resizeRowToContents(current_row);
48
49 column_width =
50 _widget.columnWidth(0) +
51 _widget.columnWidth(1) +
52 _widget.columnWidth(2) +
53 2;
54
55 _widget.setMinimumWidth(column_width);
56 _widget.setMinimumHeight(_widget.rowHeight(0) * (_widget.rowCount()) + 2);
57 _widget.setMaximumHeight(_widget.rowHeight(0) * (_widget.rowCount()) + 2);
58
59
60 dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25;
61 dx = column_width + 10;
62 if (dx < 270) dx = 270;
63 }