Files

106 lines
1.8 KiB
C++
Raw Permalink Normal View History

2016-04-13 08:10:24 +02:00
#pragma once
2015-12-17 23:43:27 +01:00
#include <QtCore/QUuid>
#include <QtWidgets/QGraphicsObject>
#include "Connection.hpp"
#include "NodeGeometry.hpp"
#include "NodeState.hpp"
2017-01-30 10:31:43 +01:00
class QGraphicsProxyWidget;
namespace QtNodes
{
class FlowScene;
2015-12-17 23:43:27 +01:00
class FlowItemEntry;
2016-04-13 08:10:24 +02:00
/// Class reacts on GUI events, mouse clicks and
/// forwards painting operation.
2015-12-17 23:43:27 +01:00
class NodeGraphicsObject : public QGraphicsObject
{
Q_OBJECT
public:
NodeGraphicsObject(FlowScene &scene,
Node& node);
2015-12-17 23:43:27 +01:00
2016-09-20 22:49:52 +02:00
virtual
~NodeGraphicsObject();
Node&
2016-09-18 15:05:14 +02:00
node();
2015-12-17 23:43:27 +01:00
Node const&
node() const;
2016-09-18 15:05:14 +02:00
QRectF
boundingRect() const override;
2015-12-17 23:43:27 +01:00
2016-09-18 15:05:14 +02:00
void
setGeometryChanged();
/// Visits all attached connections and corrects
/// their corresponding end points.
2016-09-18 15:05:14 +02:00
void
moveConnections() const;
2015-12-17 23:43:27 +01:00
enum { Type = UserType + 1 };
2017-04-22 14:29:30 +02:00
int
type() const override { return Type; }
void
lock(bool locked);
2015-12-17 23:43:27 +01:00
protected:
2016-09-18 15:05:14 +02:00
void
paint(QPainter* painter,
QStyleOptionGraphicsItem const* option,
QWidget* widget = 0) override;
2015-12-17 23:43:27 +01:00
2016-09-20 15:22:05 +01:00
QVariant
itemChange(GraphicsItemChange change, const QVariant &value) override;
2016-09-18 15:05:14 +02:00
void
mousePressEvent(QGraphicsSceneMouseEvent* event) override;
2015-12-17 23:43:27 +01:00
2016-09-18 15:05:14 +02:00
void
mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
2015-12-17 23:43:27 +01:00
2016-09-18 15:05:14 +02:00
void
mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
2016-09-18 15:05:14 +02:00
void
hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
2015-12-17 23:43:27 +01:00
2016-09-18 15:05:14 +02:00
void
hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
void
hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
2015-12-17 23:43:27 +01:00
2017-02-21 01:57:44 -08:00
void
mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
void
contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
2015-12-17 23:43:27 +01:00
private:
2016-09-18 15:05:14 +02:00
void
embedQWidget();
2015-12-17 23:43:27 +01:00
private:
FlowScene & _scene;
2015-12-17 23:43:27 +01:00
Node& _node;
2016-05-30 16:37:11 +02:00
bool _locked;
2016-05-30 16:37:11 +02:00
// either nullptr or owned by parent QGraphicsItem
QGraphicsProxyWidget * _proxyWidget;
2015-12-17 23:43:27 +01:00
};
2017-01-30 10:31:43 +01:00
}