graphpoint.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "graphpoint.h"
  2. GraphPoint::GraphPoint(const GitOid &commitOid, QObject* parent) : QObject(parent)
  3. ,m_commitOid(commitOid)
  4. ,m_x(0)
  5. ,m_y(0)
  6. {
  7. }
  8. GraphPoint::GraphPoint(const GitOid &commitOid, int x, int y, const QString &color, QObject *parent) : QObject(parent)
  9. ,m_commitOid(commitOid)
  10. ,m_x(x)
  11. ,m_y(y)
  12. ,m_color(color)
  13. {
  14. }
  15. GraphPoint::~GraphPoint()
  16. {
  17. }
  18. void GraphPoint::setX(int x)
  19. {
  20. if (m_x == x) {
  21. return;
  22. }
  23. m_x = x;
  24. emit xChanged(x);
  25. }
  26. void GraphPoint::setY(int y)
  27. {
  28. if (m_y == y) {
  29. return;
  30. }
  31. m_y = y;
  32. emit yChanged(y);
  33. }
  34. void GraphPoint::setColor(const QString& color)
  35. {
  36. if (m_color == color) {
  37. return;
  38. }
  39. m_color = color;
  40. emit colorChanged(color);
  41. }
  42. bool GraphPoint::addChildPoint(GraphPoint* point)
  43. {
  44. bool orderChanged = false;
  45. if(m_childPoints.indexOf(point) < 0) {
  46. if(point->x() < x()) {
  47. for(int i = 0; i < m_childPoints.count(); i++) {
  48. GraphPoint* child = static_cast<GraphPoint*>(m_childPoints.at(i));
  49. child->setX(child->x() + 1);
  50. }
  51. orderChanged = true;
  52. }
  53. m_childPoints.append(point);
  54. }
  55. return orderChanged;
  56. }