repositorymodel.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef REPOSITORYMODEL_H
  2. #define REPOSITORYMODEL_H
  3. #include <universallistmodel.h>
  4. #include <gitrepository.h>
  5. #include <QString>
  6. #include <QPointer>
  7. class RepositoryModel : public UniversalListModel<GitRepository>
  8. {
  9. Q_OBJECT
  10. Q_PROPERTY(int activeRepositoryIndex READ activeRepositoryIndex NOTIFY activeRepositoryIndexChanged)
  11. public:
  12. RepositoryModel(QObject *parent = 0);
  13. ~RepositoryModel();
  14. void addRepository(GitRepository* repository);
  15. void removeRepository(GitRepository* repository);
  16. int activeRepositoryIndex() const
  17. {
  18. return m_activeRepositoryIndex;
  19. }
  20. public slots:
  21. void setActiveRepositoryIndex(int activeRepositoryIndex)
  22. {
  23. if (m_activeRepositoryIndex == activeRepositoryIndex)
  24. return;
  25. m_activeRepositoryIndex = activeRepositoryIndex;
  26. emit activeRepositoryIndexChanged(activeRepositoryIndex);
  27. }
  28. signals:
  29. void activeRepositoryIndexChanged(int activeRepositoryIndex);
  30. private:
  31. QList<QString> m_repolist;
  32. int m_activeRepositoryIndex;
  33. };
  34. #endif // REPOSITORYMODEL_H