From 93c5ade08250e419b7dbc3177db6fba93163fd34 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 13 Feb 2019 18:37:51 +0100 Subject: Include simple serial port terminal and prepare empty peripheral dock. Signed-off-by: Pavel Pisa --- qtmips_gui/coreview/logicblock.cpp | 9 +++++++-- qtmips_gui/coreview/logicblock.h | 12 ++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'qtmips_gui/coreview') diff --git a/qtmips_gui/coreview/logicblock.cpp b/qtmips_gui/coreview/logicblock.cpp index 2aabe7f..e2c5e24 100644 --- a/qtmips_gui/coreview/logicblock.cpp +++ b/qtmips_gui/coreview/logicblock.cpp @@ -47,7 +47,7 @@ using namespace coreview; LogicBlock::LogicBlock(QString name) : LogicBlock(QVector({name})) { } -LogicBlock::LogicBlock(QVector name) : QGraphicsItem(nullptr) { +LogicBlock::LogicBlock(QVector name) : QGraphicsObject(nullptr) { QFont font; font.setPointSize(7); @@ -82,7 +82,7 @@ void LogicBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option } void LogicBlock::setPos(qreal x, qreal y) { - QGraphicsItem::setPos(x, y); + QGraphicsObject::setPos(x, y); for (int i = 0; i < connectors.size(); i++) { struct Con &c = connectors[i]; c.con->setPos(x + c.p.x(), y + c.p.y()); @@ -134,3 +134,8 @@ QPointF LogicBlock::con_pos(qreal x, qreal y) { py += GAP * sign(y); return QPointF(px, py); } + +void LogicBlock::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { + QGraphicsObject::mouseDoubleClickEvent(event); + emit open_block(); +} diff --git a/qtmips_gui/coreview/logicblock.h b/qtmips_gui/coreview/logicblock.h index 27c2951..a384b06 100644 --- a/qtmips_gui/coreview/logicblock.h +++ b/qtmips_gui/coreview/logicblock.h @@ -36,15 +36,17 @@ #ifndef LOGICBLOCK_H #define LOGICBLOCK_H -#include +#include #include #include #include +#include #include "connection.h" namespace coreview { -class LogicBlock : public QGraphicsItem { +class LogicBlock : public QGraphicsObject { + Q_OBJECT public: LogicBlock(QString name); LogicBlock(QVector name); @@ -61,6 +63,9 @@ public: // Using x=y and x=-y coordinates is not supported const Connector *new_connector(qreal x, qreal y); +signals: + void open_block(); + private: QVector text; QRectF box; @@ -72,6 +77,9 @@ private: }; QVector connectors; QPointF con_pos(qreal x, qreal y); + +protected: + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); }; } -- cgit v1.2.3