gitoid.h 967 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef GITOID_H
  2. #define GITOID_H
  3. #include <QObject>
  4. #include <QString>
  5. #include <git2/oid.h>
  6. #include <QDebug>
  7. class GitRepository;
  8. class GitOid : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. GitOid();
  13. GitOid(const git_oid* oid, GitRepository *parent);
  14. GitOid(const GitOid& other);
  15. bool operator ==(const GitOid& other) const;
  16. bool operator <(const GitOid& other) const;
  17. GitOid& operator=(const GitOid& other);
  18. const git_oid* raw() const {
  19. return &m_oid;
  20. }
  21. GitRepository* repository() const {
  22. return m_repository;
  23. }
  24. Q_INVOKABLE QString toString() const;
  25. QString toShorten() const;
  26. bool isValid() const;
  27. private:
  28. void updateOid(const git_oid* oid);
  29. git_oid m_oid;
  30. QString m_string;
  31. GitRepository *m_repository;
  32. };
  33. inline uint qHash(const GitOid& oid) {
  34. return qHash(QByteArray((const char*)(oid.raw()->id), GIT_OID_RAWSZ));
  35. }
  36. Q_DECLARE_METATYPE(GitOid)
  37. #endif // GITOID_H