X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.hxx;h=30f2babce3ff260d84b0152b9987423739304408;hp=3c61121c75fa3da7f7e55894dc723c3f15e2e5be;hb=459e107cb0f6fcf17618e06837fc8ff5b3f0ce8d;hpb=d51782798930575415d53300340ede3a004f1661 diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 3c61121..30f2bab 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -5,62 +5,45 @@ #include "disassembler/BasicBlock.hxx" #include #include +#include +#include class BasicBlockWidget : public QGraphicsItem { public: - BasicBlockWidget(const QString& name, BasicBlock * block); + BasicBlockWidget(const QString& name, BasicBlock * block); - void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); + void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href); - QRectF boundingRect() const { - qreal penWidth = 1; - QRectF result(x - penWidth / 2, y - penWidth / 2, - dx + penWidth, dy + penWidth); - - - if (next[0]) - result |= QRectF(QPointF(x + dx/3, y+dy), - mapFromScene(next[0]->getEntry())); - - if (next[1]) - result |= QRectF(QPointF(x + 2*dx/3, y+dy), - mapFromScene(next[1]->getEntry())); + QRectF boundingRect() const { + qreal penWidth = 1; + QRectF result(- penWidth / 2, - penWidth / 2, + width + penWidth, height + penWidth); + return result; + } - return result; - } - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + void mouseMoveEvent(QGraphicsSceneMouseEvent * event) { QGraphicsItem::mouseMoveEvent(event); - std::for_each(previous.begin(), previous.end(), - [&] (BasicBlockWidget * item) { - item->update(boundingRect() | item->boundingRect()); - }); + scene()->update(); } QPointF getEntry() const { - return mapToScene(QPointF(x + dx/2, y)); + return mapToScene(QPointF(width/2, 0)); } - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) { - painter->fillRect(x, y, dx, dy, QColor(0xcc, 0xcc, 0xff, 0xff)); - painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); - painter->drawRect(x, y, dx, dy); - painter->drawText(0, -5, name); - if (_widget.rowCount() != 0) - _widget.render(painter); - - painter->setPen(QColor(0x00, 0xff, 0x00, 0xff)); - if (next[0]) - painter->drawLine(QPointF(x + dx/3, y+dy), - mapFromScene(next[0]->getEntry())); - - painter->setPen(QColor(0xff, 0x00, 0x00, 0xff)); - if (next[1]) - painter->drawLine(QPointF(x + 2*dx/3, y+dy), - mapFromScene(next[1]->getEntry())); + std::array getExits() const { + return { { mapToScene(QPointF( width/3, height)), + mapToScene(QPointF( width/2, height)), + mapToScene(QPointF(2*width/3, height)) } }; + } - } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget) { + painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff)); + painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); + painter->drawRect(0, 0, width, height); + painter->drawText(5, 15, name); + } void addPrevious(BasicBlockWidget * widget) { previous.push_back(widget); @@ -71,9 +54,17 @@ public: next[1] = right; } + BasicBlockWidget ** getNext() { + return next; + } + + QString getName() const { + return name; + } private: - int x, y, dx, dy; - QTableWidget _widget; + uint32_t width, height; + QGraphicsProxyWidget _proxy; + QTableWidget _widget; QString name; BasicBlock * block; std::vector previous;