graphpoint.h 1.5 KB

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