memberships.h 850 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef MEMBERSHIPS_H
  2. #define MEMBERSHIPS_H
  3. #include <QObject>
  4. #include <QHash>
  5. #include <QJsonObject>
  6. #include <QJsonArray>
  7. class Memberships
  8. {
  9. public:
  10. Memberships();
  11. struct membership_role {
  12. int role_id;
  13. bool isInherited;
  14. };
  15. struct membership {
  16. int id;
  17. int project_id;
  18. int user_id;
  19. QString user_name;
  20. QList<struct membership_role> roles;
  21. };
  22. struct membership get ( int membership_id );
  23. QList<struct membership> get_byproject ( int project_id );
  24. void set ( QJsonArray json_array );
  25. private:
  26. QList <struct membership> list;
  27. QHash <int, struct membership> id2membership;
  28. QHash <int, QList<struct membership>> projectId2membership;
  29. void add ( QJsonObject json_membership );
  30. void clear();
  31. };
  32. #endif // MEMBERSHIPS_H