GemRepoModel.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <QStandardItemModel>
  11. #include <GemRepo/GemRepoInfo.h>
  12. #include <TagWidget.h>
  13. #endif
  14. QT_FORWARD_DECLARE_CLASS(QItemSelectionModel)
  15. namespace O3DE::ProjectManager
  16. {
  17. class GemRepoModel
  18. : public QStandardItemModel
  19. {
  20. Q_OBJECT
  21. public:
  22. explicit GemRepoModel(QObject* parent = nullptr);
  23. QItemSelectionModel* GetSelectionModel() const;
  24. void AddGemRepo(const GemRepoInfo& gemInfo);
  25. void Clear();
  26. static QString GetName(const QModelIndex& modelIndex);
  27. static QString GetCreator(const QModelIndex& modelIndex);
  28. static QString GetSummary(const QModelIndex& modelIndex);
  29. static QString GetAdditionalInfo(const QModelIndex& modelIndex);
  30. static QString GetDirectoryLink(const QModelIndex& modelIndex);
  31. static QString GetRepoUri(const QModelIndex& modelIndex);
  32. static QDateTime GetLastUpdated(const QModelIndex& modelIndex);
  33. static QString GetPath(const QModelIndex& modelIndex);
  34. static GemRepoInfo::BadgeType GetBadgeType(const QModelIndex& modelIndex);
  35. static QVector<Tag> GetIncludedGemTags(const QModelIndex& modelIndex);
  36. static QVector<Tag> GetIncludedProjectTags(const QModelIndex& modelIndex);
  37. static QVector<Tag> GetIncludedProjectTemplateTags(const QModelIndex& modelIndex);
  38. static bool IsEnabled(const QModelIndex& modelIndex);
  39. static void SetEnabled(QAbstractItemModel& model, const QModelIndex& modelIndex, bool isEnabled);
  40. static bool HasAdditionalInfo(const QModelIndex& modelIndex);
  41. enum UserRole
  42. {
  43. RoleName = Qt::UserRole,
  44. RoleCreator,
  45. RoleSummary,
  46. RoleIsEnabled,
  47. RoleDirectoryLink,
  48. RoleRepoUri,
  49. RoleLastUpdated,
  50. RolePath,
  51. RoleAdditionalInfo,
  52. RoleIncludedGems,
  53. RoleIncludedProjects,
  54. RoleIncludedProjectTemplates,
  55. RoleBadgeType
  56. };
  57. void SetRepoEnabled(const QModelIndex& modelIndex, bool isEnabled);
  58. QPersistentModelIndex FindModelIndexByRepoUri(const QString& repoUri);
  59. signals:
  60. void ShowToastNotification(const QString& notification);
  61. private:
  62. QItemSelectionModel* m_selectionModel = nullptr;
  63. };
  64. } // namespace O3DE::ProjectManager