graphpoint.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef GRAPHPOINT_H
  2. #define GRAPHPOINT_H
  3. #include <QList>
  4. #include <QObject>
  5. #include <gitoid.h>
  6. class GraphPoint : public QObject
  7. {
  8. Q_OBJECT
  9. Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
  10. Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
  11. Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
  12. Q_PROPERTY(QList<QObject*> childPoints READ childPoints CONSTANT)
  13. Q_PROPERTY(GitOid oid READ oid CONSTANT)
  14. public:
  15. GraphPoint(const GitOid& commitOid, QObject* parent = 0);
  16. GraphPoint(const GitOid& commitOid, int x, int y, const QString& color, QObject* parent = 0);
  17. ~GraphPoint();
  18. int x() const {
  19. return m_x;
  20. }
  21. int y() const {
  22. return m_y;
  23. }
  24. QString color() const {
  25. return m_color;
  26. }
  27. const GitOid& oid() const {
  28. return m_commitOid;
  29. }
  30. int childPointsCount() const {
  31. return m_childPoints.count();
  32. }
  33. QList<QObject*> childPoints() const {
  34. return m_childPoints;
  35. }
  36. bool addChildPoint(GraphPoint* point);
  37. public slots:
  38. void setX(int x);
  39. void setY(int y);
  40. void setColor(const QString& color);
  41. signals:
  42. void xChanged(int x);
  43. void yChanged(int y);
  44. void colorChanged(const QString& color);
  45. private:
  46. GitOid m_commitOid;
  47. QList<QObject*> m_childPoints;
  48. int m_x;
  49. int m_y;
  50. QString m_color;
  51. };
  52. #endif // GRAPTHPOINT_H