mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#ifndef APISUBSCRIPTIONPLANSMODEL_H
|
|
#define APISUBSCRIPTIONPLANSMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QJsonArray>
|
|
#include <QVector>
|
|
|
|
class ApiSubscriptionPlansModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Roles {
|
|
PrimaryLeftRole = Qt::UserRole + 1,
|
|
PrimaryRightRole,
|
|
SubtitleRole,
|
|
RecommendedRole,
|
|
CheckoutUrlRole,
|
|
IsTrialRole,
|
|
ServiceProtocolRole,
|
|
StoreProductIdRole
|
|
};
|
|
Q_ENUM(Roles)
|
|
|
|
explicit ApiSubscriptionPlansModel(QObject *parent = nullptr);
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
void updateModel(const QJsonArray &arr);
|
|
void clear();
|
|
|
|
Q_INVOKABLE QVariantMap planAt(int row) const;
|
|
Q_INVOKABLE int recommendedRowIndex() const;
|
|
|
|
private:
|
|
struct SubscriptionPlanItem
|
|
{
|
|
QString primaryLeft;
|
|
QString primaryRight;
|
|
QString subtitle;
|
|
bool recommended = false;
|
|
QString checkoutUrl;
|
|
bool isTrial = false;
|
|
QString serviceProtocol;
|
|
QString storeProductId;
|
|
};
|
|
|
|
QVector<SubscriptionPlanItem> m_subscriptionPlans;
|
|
};
|
|
|
|
#endif
|