githandler.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef GITHANDLER_H
  2. #define GITHANDLER_H
  3. #include <QObject>
  4. #include <repositorymodel.h>
  5. class CommitModel;
  6. class CommitGraph;
  7. typedef QHash<QString, QPointer<CommitModel>> CommitModelContainer;
  8. class GitHandler : public QObject
  9. {
  10. Q_OBJECT
  11. Q_PROPERTY(RepositoryModel* repositories READ repositories NOTIFY repositoriesChanged)
  12. Q_PROPERTY(CommitGraph* graph READ graph WRITE setGraph NOTIFY graphChanged)
  13. public:
  14. GitHandler();
  15. virtual ~GitHandler();
  16. Q_INVOKABLE void open(const QString &path);
  17. Q_INVOKABLE void open(const QUrl &url);
  18. RepositoryModel* repositories() const
  19. {
  20. return m_repositories;
  21. }
  22. Q_INVOKABLE CommitModel* modelByHead(const QString& head);
  23. CommitGraph* graph() const
  24. {
  25. return m_graph;
  26. }
  27. public slots:
  28. void setGraph(CommitGraph* graph)
  29. {
  30. if (m_graph == graph)
  31. return;
  32. m_graph = graph;
  33. emit graphChanged(graph);
  34. }
  35. signals:
  36. void repositoriesChanged(RepositoryModel* repositories);
  37. void graphChanged(CommitGraph* graph);
  38. protected:
  39. QString lastError() const;
  40. private:
  41. RepositoryModel* m_repositories;
  42. CommitModelContainer m_commits;
  43. CommitGraph* m_graph;
  44. };
  45. #endif // GITHANDLER_H