graphpoint.h 1.5 KB

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