From: Christoph Egger Date: Wed, 7 Jan 2015 20:41:22 +0000 (+0100) Subject: Use QGraphicsProxyWidget X-Git-Tag: v0.1~142 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=4bcd18ed3dc3450d014351f5b27d1c7d1596601c;p=frida%2Ffrida.git Use QGraphicsProxyWidget This way the qlabel widget can be accessed properly (clicking and stuff) --- diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index ab06f88..2003458 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -2,9 +2,13 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block) : width(270), height(45) - , name(name), block(block) { + , name(name), block(block) + , _proxy(this) { next[0] = NULL; next[1] = NULL; - _widget.move(5, 20); + _proxy.setWidget(&_widget); + _widget.setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse); + + _proxy.setPos(5, 20); if (width < 270) width = 270; } @@ -22,7 +26,7 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, QString old_text = _widget.text(); if (old_text == "") { - old_text = ""; + old_text = "
"; } QString new_text = old_text.remove("
") + @@ -32,6 +36,7 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, ""; _widget.setText(new_text); + _widget.resize(_widget.sizeHint().width(), _widget.sizeHint().height()); width = 12 + _widget.sizeHint().width(); height = 25 + _widget.sizeHint().height(); diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 2dcc80c..8aa182f 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -43,8 +43,6 @@ public: painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); painter->drawRect(0, 0, width, height); painter->drawText(5, 15, name); - if (_widget.text() != "") - _widget.render(painter, QPoint(5, 20)); } void addPrevious(BasicBlockWidget * widget) { @@ -62,6 +60,7 @@ public: private: uint32_t width, height; + QGraphicsProxyWidget _proxy; QLabel _widget; QString name; BasicBlock * block; diff --git a/src/gui/widgets/CFGScene.cxx b/src/gui/widgets/CFGScene.cxx index ec33463..4e7428d 100644 --- a/src/gui/widgets/CFGScene.cxx +++ b/src/gui/widgets/CFGScene.cxx @@ -93,6 +93,7 @@ void CFGScene::spaceWidgets() { relevantRect.adjust(-20, -20, 20, 20); for (QGraphicsItem * item : items(relevantRect)) { if (item == widget) continue; + if (std::find(widgets.begin(), widgets.end(), item) == widgets.end()) continue; QRectF itemrect = item->boundingRect(); itemrect.moveTo(item->scenePos()); while (relevantRect.intersects(itemrect)) {