]>
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), name(name
)
7 , _widget("", this), _table(NULL
)
8 , block(block
), mainwindow(mainwindow
) {
9 next
[0] = NULL
; next
[1] = NULL
;
10 _widget
.setPos(5, 20);
11 _widget
.setTextInteractionFlags(Qt::TextSelectableByMouse
|
12 Qt::LinksAccessibleByMouse
);
14 if (width
< 250) width
= 250;
17 void BasicBlockWidget::addItem(uint8_t* bytes
, size_t num_bytes
,
18 QString line
, const QString
& href
) {
24 _table
->appendRows(1);
27 QTextTableFormat format
;
28 format
.setBorderStyle(QTextFrameFormat::BorderStyle_None
);
30 _table
= _widget
.textCursor().insertTable(1, 3, format
);
33 for (size_t i(0); i
< num_bytes
; ++i
) {
34 const char * hexdigits
= "0123456789ABCDEF";
35 bytestring
+= hexdigits
[(bytes
[i
] >> 4) & 0xF];
36 bytestring
+= hexdigits
[bytes
[i
] & 0xF];
40 _table
->cellAt(row
, 0).firstCursorPosition().insertText(bytestring
);
42 line
= line
.replace('\t', ' ').toHtmlEscaped();
44 line
= "<a href=\"" + href
+ "\">" + line
+ "</a>";
47 _table
->cellAt(row
, 1).firstCursorPosition().insertHtml(line
);
49 QObject::connect(&_widget
, &QGraphicsTextItem::linkActivated
,
51 if (str
.startsWith("function:")) {
52 QString address
= str
.remove("function:");
53 mainwindow
->switchMainPlaneToAddress(address
.toInt(NULL
, 16));
57 width
= 10 + _widget
.boundingRect().width();
58 height
= 25 + _widget
.boundingRect().height();
60 if (width
< 250) width
= 250;
63 void BasicBlockWidget::paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
,
65 painter
->fillRect(0, 0, width
, height
, QColor(0xcc, 0xcc, 0xff, 0xff));
66 painter
->setPen(QColor(0x00, 0x00, 0xff, 0xff));
67 painter
->drawRect(0, 0, width
, height
);
68 painter
->drawText(5, 15, name
);
71 QRectF
BasicBlockWidget::boundingRect() const {
73 QRectF
result(- penWidth
/ 2, - penWidth
/ 2,
74 width
+ penWidth
, height
+ penWidth
);
78 std::array
<QPointF
, 3> BasicBlockWidget::getExits() const {
79 return { { mapToScene(QPointF( width
/3, height
)),
80 mapToScene(QPointF( width
/2, height
)),
81 mapToScene(QPointF(2*width
/3, height
)) } };