commitgraph.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef COMMITGRAPH_H
  2. #define COMMITGRAPH_H
  3. #include <QObject>
  4. #include <gitoid.h>
  5. #include <QString>
  6. #include <QHash>
  7. #include <QList>
  8. #include <QPointer>
  9. class GitCommit;
  10. class GraphPoint;
  11. class GraphListModel;
  12. class GitBranch;
  13. class GitDiff;
  14. class CommitGraph : public QObject
  15. {
  16. Q_OBJECT
  17. Q_PROPERTY(GraphListModel* points READ points NOTIFY pointsChanged)
  18. Q_PROPERTY(int branchesCount READ branchesCount NOTIFY branchesCountChanged)
  19. public:
  20. CommitGraph();
  21. void addHead(GitBranch* branch);
  22. void addHead(const GitOid& oid);
  23. GraphListModel* points() const {
  24. return m_pointsModel;
  25. }
  26. int branchesCount() const
  27. {
  28. return m_branchesCount;
  29. }
  30. Q_INVOKABLE GraphPoint* point(const GitOid& oid);
  31. Q_INVOKABLE GraphPoint* point(int i);
  32. signals:
  33. void branchesCountChanged(int branchesCount);
  34. void pointsChanged(GraphListModel* points);
  35. private:
  36. void findParents(GitCommit *commit);
  37. void addCommits(QList<GitOid> &reversList);
  38. QString m_color;
  39. QHash<GitOid, GraphPoint*> m_points;
  40. QList<QPointer<GraphPoint> > m_sortedPoints;
  41. GraphListModel* m_pointsModel;
  42. int m_branchesCount;
  43. };
  44. #endif // COMMITGRAPH_H