gitbranch.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef GITBRANCH_H
  2. #define GITBRANCH_H
  3. #include <gitreference.h>
  4. #include <git2/types.h>
  5. struct git_oid;
  6. class GitBranch : public GitReference
  7. {
  8. Q_OBJECT
  9. Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
  10. Q_PROPERTY(QString fullName READ fullName NOTIFY fullNameChanged)
  11. Q_PROPERTY(QString remote READ remote NOTIFY remoteChanged)
  12. Q_PROPERTY(BranchType type READ type CONSTANT)
  13. Q_PROPERTY(GitOid oid READ oid CONSTANT)
  14. Q_ENUMS(BranchType)
  15. public:
  16. enum BranchType {
  17. Local = GIT_BRANCH_LOCAL,
  18. Remote = GIT_BRANCH_REMOTE
  19. };
  20. GitBranch(git_reference* ref, git_branch_t type, GitRepository* parent);
  21. virtual ~GitBranch();
  22. BranchType type() const;
  23. QString name() const {
  24. return m_name;
  25. }
  26. QString fullName() const {
  27. return m_fullName;
  28. }
  29. git_annotated_commit* annontatedCommit()
  30. {
  31. return m_commit;
  32. }
  33. QString remote() const
  34. {
  35. return m_remote;
  36. }
  37. public slots:
  38. void setName(QString name) {
  39. if (m_name == name)
  40. return;
  41. m_name = name;
  42. emit nameChanged(name);
  43. }
  44. signals:
  45. void nameChanged(QString name);
  46. void fullNameChanged(QString fullName);
  47. void remoteChanged(QString remote);
  48. private:
  49. void free();
  50. GitBranch();
  51. Q_DISABLE_COPY(GitBranch)
  52. git_annotated_commit* m_commit;
  53. BranchType m_type;
  54. QString m_name;
  55. QString m_fullName;
  56. QString m_remote;
  57. };
  58. #endif // GITBRANCH_H