From: Christoph Egger Date: Tue, 17 Feb 2015 15:30:54 +0000 (+0100) Subject: Compactify BasicBlockWidget header X-Git-Tag: v0.1~108 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=e75c3d69cb2ebf78e156932deb136c0346b10234;p=frida%2Ffrida.git Compactify BasicBlockWidget header --- diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index eccb679..f611329 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -3,16 +3,14 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow) - : width(270), height(45) - , _widget("", this) - , _table(NULL), name(name) + : width(270), height(45), name(name) + , _widget("", this), _table(NULL) , block(block), mainwindow(mainwindow) { next[0] = NULL; next[1] = NULL; + _widget.setPos(5, 20); _widget.setTextInteractionFlags(Qt::TextSelectableByMouse| Qt::LinksAccessibleByMouse); - _widget.setPos(5, 20); - if (width < 250) width = 250; } @@ -61,3 +59,25 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, if (width < 250) width = 250; } + +void BasicBlockWidget::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); +} + +QRectF BasicBlockWidget::boundingRect() const { + qreal penWidth = 1; + QRectF result(- penWidth / 2, - penWidth / 2, + width + penWidth, height + penWidth); + return result; +} + +std::array BasicBlockWidget::getExits() const { + return { { mapToScene(QPointF( width/3, height)), + mapToScene(QPointF( width/2, height)), + mapToScene(QPointF(2*width/3, height)) } }; +} + diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 8ee33a5..2122bf2 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -17,60 +17,35 @@ public: BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow); void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + QRectF boundingRect() const; + std::array getExits() const; - QRectF boundingRect() const { - qreal penWidth = 1; - QRectF result(- penWidth / 2, - penWidth / 2, - width + penWidth, height + penWidth); - return result; - } - - void mouseMoveEvent(QGraphicsSceneMouseEvent * event) { - QGraphicsItem::mouseMoveEvent(event); - scene()->update(); - } - - QPointF getEntry() const { - return mapToScene(QPointF(width/2, 0)); - } + void mouseMoveEvent(QGraphicsSceneMouseEvent * event) + { QGraphicsItem::mouseMoveEvent(event); scene()->update(); } - std::array getExits() const { - return { { mapToScene(QPointF( width/3, height)), - mapToScene(QPointF( width/2, height)), - mapToScene(QPointF(2*width/3, height)) } }; - } + QPointF getEntry() const + { return mapToScene(QPointF(width/2, 0)); } - 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); } - void addPrevious(BasicBlockWidget * widget) { - previous.push_back(widget); - } + void addNext(BasicBlockWidget * left, BasicBlockWidget * right) + { next[0] = left; next[1] = right; } - void addNext(BasicBlockWidget * left, BasicBlockWidget * right) { - next[0] = left; - next[1] = right; - } + BasicBlockWidget ** getNext() + { return next; } - BasicBlockWidget ** getNext() { - return next; - } - - QString getName() const { - return name; - } + QString getName() const + { return name; } private: uint32_t width, height; + QString name; QGraphicsTextItem _widget; QTextTable* _table; - QString name; - BasicBlock * block; - Mainwindow * mainwindow; + BasicBlock* block; + Mainwindow* mainwindow; std::vector previous; BasicBlockWidget* next[2]; };