graphpoint.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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(QString tag READ tag CONSTANT)
  15. Q_PROPERTY(QString branch READ branch CONSTANT)
  16. public:
  17. GraphPoint(const GitOid& commitOid, QObject* parent = 0);
  18. GraphPoint(const GitOid& commitOid, int x, int y, const QString& color, QObject* parent = 0);
  19. ~GraphPoint();
  20. int x() const
  21. {
  22. return m_x;
  23. }
  24. int y() const
  25. {
  26. return m_y;
  27. }
  28. QString color() const
  29. {
  30. return m_color;
  31. }
  32. const GitOid& oid() const
  33. {
  34. return m_commitOid;
  35. }
  36. QString sha1() const
  37. {
  38. return m_commitOid.toString();
  39. }
  40. int childPointsCount() const
  41. {
  42. return m_childPoints.count();
  43. }
  44. bool addChildPoint(GraphPoint* point);
  45. QList<QObject*> childPoints() const
  46. {
  47. return m_childPoints;
  48. }
  49. QString tag() const
  50. {
  51. return m_tag;
  52. }
  53. QString branch() const
  54. {
  55. return m_branch;
  56. }
  57. public slots:
  58. void setX(int x);
  59. void setY(int y);
  60. void setColor(const QString& color);
  61. void setTag(QString tag)
  62. {
  63. m_tag = tag;
  64. }
  65. void setBranch(QString branch)
  66. {
  67. m_branch = branch;
  68. }
  69. signals:
  70. void xChanged(int x);
  71. void yChanged(int y);
  72. void colorChanged(const QString& color);
  73. private:
  74. GitOid m_commitOid;
  75. QList<QObject*> m_childPoints;
  76. int m_x;
  77. int m_y;
  78. QString m_color;
  79. QString m_tag;
  80. QString m_branch;
  81. };
  82. #endif // GRAPTHPOINT_H