commitgraph.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. void addWorkdir();
  24. GraphListModel* points() const {
  25. return m_pointsModel;
  26. }
  27. int branchesCount() const
  28. {
  29. return m_branchesCount;
  30. }
  31. Q_INVOKABLE GraphPoint* point(const GitOid& oid);
  32. Q_INVOKABLE GraphPoint* point(int i);
  33. signals:
  34. void branchesCountChanged(int branchesCount);
  35. void pointsChanged(GraphListModel* points);
  36. private:
  37. void findParents(GitCommit *commit);
  38. void addCommits(QList<GitOid> &reversList);
  39. void checkRoot(GitCommit *commit);
  40. QString m_color;
  41. QHash<GitOid, GraphPoint*> m_points;
  42. QList<QPointer<GraphPoint> > m_sortedPoints;
  43. GraphListModel* m_pointsModel;
  44. int m_branchesCount;
  45. };
  46. #endif // COMMITGRAPH_H