repositorymodel.h 829 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef REPOSITORYMODEL_H
  2. #define REPOSITORYMODEL_H
  3. #include <QAbstractListModel>
  4. #include <QHash>
  5. #include <QString>
  6. #include <QPointer>
  7. class GitRepository;
  8. class RepositoryModel : public QAbstractListModel
  9. {
  10. Q_OBJECT
  11. public:
  12. enum Roles {
  13. RepoName,
  14. RepoRoot,
  15. RepoBranches
  16. };
  17. RepositoryModel(QObject *parent = 0);
  18. ~RepositoryModel();
  19. bool addRepository(GitRepository* repo);
  20. void removeRepository(GitRepository* repo);
  21. void removeRepository(const QString& root);
  22. QVariant data(const QModelIndex &index, int role) const;
  23. int rowCount(const QModelIndex &parent) const;
  24. QHash<int, QByteArray> roleNames() const;
  25. private:
  26. QHash<QString, QPointer<GitRepository>> m_repositories;
  27. static QHash<int, QByteArray> m_roles;
  28. };
  29. #endif // REPOSITORYMODEL_H