]>
git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.cxx
1 #include "BasicBlockWidget.hxx"
2 #include "gui/Mainwindow.hxx"
4 BasicBlockWidget::BasicBlockWidget(const QString
& name
, BasicBlock
* block
,
5 Mainwindow
* mainwindow
)
6 : width(270), height(45)
7 , _proxy(this), name(name
)
8 , block(block
), mainwindow(mainwindow
) {
9 next
[0] = NULL
; next
[1] = NULL
;
10 _widget
.setStyleSheet("QWidget { background-color : #ddddff; }");
11 _widget
.setLayout(&_layout
);
12 _layout
.setContentsMargins(0, 0, 0, 0);
13 _proxy
.setWidget(&_widget
);
16 if (width
< 250) width
= 250;
19 void BasicBlockWidget::addItem(uint8_t* bytes
, size_t num_bytes
,
20 QString line
, const QString
& href
) {
23 for (size_t i(0); i
< num_bytes
; ++i
) {
24 const char * hexdigits
= "0123456789ABCDEF";
25 bytestring
+= hexdigits
[(bytes
[i
] >> 4) & 0xF];
26 bytestring
+= hexdigits
[bytes
[i
] & 0xF];
30 int current_row
= _layout
.rowCount();
31 QLabel
* bytestring_label
= new QLabel(bytestring
);
32 bytestring_label
->setTextInteractionFlags(Qt::TextSelectableByMouse
|
33 Qt::LinksAccessibleByMouse
);
34 bytestring_label
->setWordWrap(false);
35 _layout
.addWidget(bytestring_label
, current_row
, 0);
36 bytestring_label
->setVisible(true);
38 line
= line
.replace('\t', ' ').toHtmlEscaped();
40 line
= "<a href=\"" + href
+ "\">" + line
+ "</a>";
42 QLabel
* instruction_label
= new QLabel(line
);
43 instruction_label
->setTextInteractionFlags(Qt::TextSelectableByMouse
|
44 Qt::LinksAccessibleByMouse
);
45 instruction_label
->setWordWrap(false);
46 instruction_label
->setFocusPolicy(Qt::StrongFocus
);
48 QObject::connect(instruction_label
, &QLabel::linkActivated
,
50 if (str
.startsWith("function:")) {
51 QString address
= str
.remove("function:");
52 mainwindow
->switchMainPlaneToAddress(address
.toInt(NULL
, 16));
56 _layout
.addWidget(instruction_label
, current_row
, 1);
57 instruction_label
->setVisible(true);
59 width
= 12 + _widget
.childrenRect().width();
60 height
= 25 + _widget
.childrenRect().height();
62 if (width
< 250) width
= 250;
63 _widget
.resize(width
- 12, height
- 25);