File indexing completed on 2024-05-12 16:28:11

0001 // SPDX-FileCopyrightText: 2023 Shubham Arora <shubhamarora@protonmail.com>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QQmlListProperty>
0008 #include <QString>
0009 #include <QUrl>
0010 
0011 class History
0012 {
0013     Q_GADGET
0014     Q_PROPERTY(QString day MEMBER m_day)
0015     Q_PROPERTY(QString uses MEMBER m_uses)
0016     Q_PROPERTY(QString accounts MEMBER m_accounts)
0017 
0018 public:
0019     History() = default;
0020     explicit History(const QString &day, const QString &uses, const QString &accounts);
0021 
0022 private:
0023     QString m_day;
0024     QString m_uses;
0025     QString m_accounts;
0026 };
0027 
0028 class Tag
0029 {
0030     Q_GADGET
0031     Q_PROPERTY(QString name MEMBER m_name)
0032     Q_PROPERTY(QUrl url MEMBER m_url)
0033     Q_PROPERTY(bool following MEMBER m_following)
0034     Q_PROPERTY(QList<History> history READ history CONSTANT)
0035 public:
0036     Tag() = default;
0037     explicit Tag(QJsonObject obj);
0038 
0039     QString name() const;
0040     QUrl url() const;
0041     QList<History> history() const;
0042 
0043 private:
0044     void fromJson(QJsonObject obj);
0045 
0046     QString m_name;
0047     QUrl m_url;
0048     bool m_following = false;
0049     QList<History> m_history;
0050 };
0051 
0052 Q_DECLARE_METATYPE(Tag)
0053 Q_DECLARE_METATYPE(QList<History>)