commitgraph.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. QString m_color;
  40. QHash<GitOid, GraphPoint*> m_points;
  41. QList<QPointer<GraphPoint> > m_sortedPoints;
  42. GraphListModel* m_pointsModel;
  43. int m_branchesCount;
  44. };
  45. #endif // COMMITGRAPH_H