gitcommit.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef GITCOMMIT_H
  2. #define GITCOMMIT_H
  3. #include <gitbaseoid.h>
  4. #include <gittag.h>
  5. #include <QDateTime>
  6. #include <QString>
  7. #include <QList>
  8. #include <git2/types.h>
  9. class GitDiff;
  10. class GitCommit : public GitBaseOid<git_commit>
  11. {
  12. Q_OBJECT
  13. Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY commitChanged)
  14. Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY commitChanged)
  15. Q_PROPERTY(QDateTime time READ time WRITE setTime NOTIFY commitChanged)
  16. Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY commitChanged)
  17. Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY commitChanged)
  18. Q_PROPERTY(QString sha1 READ sha1 NOTIFY commitChanged)
  19. Q_PROPERTY(QString shortSha1 READ shortSha1 NOTIFY commitChanged)
  20. Q_PROPERTY(bool isMerge READ isMerge NOTIFY commitChanged)
  21. Q_PROPERTY(GitDiff* diff READ diff NOTIFY commitChanged)
  22. public:
  23. GitCommit(git_commit* raw, GitRepository* parent);
  24. ~GitCommit();
  25. static GitCommit* fromOid(const GitOid& oid);
  26. QString author() const;
  27. QDateTime time() const;
  28. QString message() const;
  29. QString email() const;
  30. QString sha1() const;
  31. QString shortSha1() const;
  32. bool isMerge() const;
  33. QString summary() const;
  34. GitDiff* diff();
  35. public slots:
  36. void setAuthor(QString author);
  37. void setTime(QDateTime time);
  38. void setMessage(QString message);
  39. void setEmail(QString email);
  40. void setSummary(QString summary);
  41. signals:
  42. void commitChanged();
  43. void bodyChanged(QString body);
  44. private:
  45. GitCommit();
  46. /*
  47. * TODO: Seems cached values are not used. Don't remember why it's done this way.
  48. * But it's better to remove them.
  49. */
  50. // QString m_author;
  51. // QDateTime m_time;
  52. // QString m_message;
  53. // QString m_email;
  54. // QString m_summary;
  55. QPointer<GitDiff> m_diff;
  56. };
  57. #endif // GITCOMMIT_H