graphpoint.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. public:
  14. GraphPoint(const GitOid& commitOid, QObject* parent = 0);
  15. GraphPoint(const GitOid& commitOid, int x, int y, const QString& color, QObject* parent = 0);
  16. ~GraphPoint();
  17. int x() const
  18. {
  19. return m_x;
  20. }
  21. int y() const
  22. {
  23. return m_y;
  24. }
  25. QString color() const
  26. {
  27. return m_color;
  28. }
  29. const GitOid& oid() const
  30. {
  31. return m_commitOid;
  32. }
  33. int childPointsCount() const
  34. {
  35. return m_childPoints.count();
  36. }
  37. void addChildPoint(GraphPoint* point)
  38. {
  39. m_childPoints.append(point);
  40. }
  41. QList<QObject*> childPoints() const
  42. {
  43. return m_childPoints;
  44. }
  45. public slots:
  46. void setX(int x);
  47. void setY(int y);
  48. void setColor(const QString& color);
  49. signals:
  50. void xChanged(int x);
  51. void yChanged(int y);
  52. void colorChanged(const QString& color);
  53. private:
  54. GitOid m_commitOid;
  55. QList<QObject*> m_childPoints;
  56. int m_x;
  57. int m_y;
  58. QString m_color;
  59. };
  60. #endif // GRAPTHPOINT_H