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