]> git.siccegge.de Git - frida/frida.git/commitdiff
Compactify BasicBlockWidget header
authorChristoph Egger <Christoph.Egger@fau.de>
Tue, 17 Feb 2015 15:30:54 +0000 (16:30 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Tue, 17 Feb 2015 15:30:54 +0000 (16:30 +0100)
src/gui/widgets/BasicBlockWidget.cxx
src/gui/widgets/BasicBlockWidget.hxx

index eccb679f35e971a2749d9a721c3153334be84bd7..f6113292dc97a325d48103693f3472caf62f5ca0 100644 (file)
@@ -3,16 +3,14 @@
 
 BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
                                    Mainwindow * mainwindow)
 
 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;
        , block(block), mainwindow(mainwindow) {
        next[0] = NULL; next[1] = NULL;
+       _widget.setPos(5, 20);
        _widget.setTextInteractionFlags(Qt::TextSelectableByMouse|
                                        Qt::LinksAccessibleByMouse);
 
        _widget.setTextInteractionFlags(Qt::TextSelectableByMouse|
                                        Qt::LinksAccessibleByMouse);
 
-       _widget.setPos(5, 20);
-
        if (width < 250) width = 250;
 }
 
        if (width < 250) width = 250;
 }
 
@@ -61,3 +59,25 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
 
        if (width < 250) width = 250;
 }
 
        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<QPointF, 3> BasicBlockWidget::getExits() const {
+       return { { mapToScene(QPointF(  width/3, height)),
+                          mapToScene(QPointF(  width/2, height)),
+                          mapToScene(QPointF(2*width/3, height)) } };
+}
+
index 8ee33a56f21a43e6bcccfb26bbde48b6e395f58f..2122bf208e6b55fa5323367fb4fd496a4c5dfeaf 100644 (file)
@@ -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);
        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<QPointF, 3> 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<QPointF, 3> 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;
 private:
        uint32_t width, height;
+       QString name;
        QGraphicsTextItem _widget;
        QTextTable* _table;
        QGraphicsTextItem _widget;
        QTextTable* _table;
-       QString name;
-       BasicBlock * block;
-       Mainwindow * mainwindow;
+       BasicBlock* block;
+       Mainwindow* mainwindow;
        std::vector<BasicBlockWidget*> previous;
        BasicBlockWidget* next[2];
 };
        std::vector<BasicBlockWidget*> previous;
        BasicBlockWidget* next[2];
 };