1 /* 2 * SPDX-FileCopyrightText: 2014 Andreas Cord-Landwehr <cordlandwehr@kde.org> 3 * 4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 7 #ifndef EDGEITEM_H 8 #define EDGEITEM_H 9 10 #include "graphtheory_export.h" 11 #include "edge.h" 12 #include <QQuickItem> 13 14 class QSGNode; 15 16 namespace GraphTheory 17 { 18 class EdgeItemPrivate; 19 20 class EdgeItem : public QQuickItem 21 { 22 Q_OBJECT 23 Q_PROPERTY(GraphTheory::Edge * edge READ edge WRITE setEdge NOTIFY edgeChanged) 24 Q_PROPERTY(QPointF origin READ origin WRITE setOrigin) 25 26 public: 27 explicit EdgeItem(QQuickItem *parent = nullptr); 28 ~EdgeItem() override; 29 Edge * edge() const; 30 void setEdge(Edge *edge); 31 /** translation of global origin (0,0) into scene coordinates **/ 32 QPointF origin() const; 33 /** set translation of global origin (0,0) into scene coordinates **/ 34 void setOrigin(const QPointF &origin); 35 36 protected: 37 QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override; 38 39 Q_SIGNALS: 40 void edgeChanged(); 41 42 private Q_SLOTS: 43 void updatePosition(); 44 void updateColor(); 45 void updateDirection(); 46 void updateVisibility(); 47 48 private: 49 Q_DISABLE_COPY(EdgeItem) 50 const QScopedPointer<EdgeItemPrivate> d; 51 }; 52 } 53 54 #endif 55