File indexing completed on 2024-12-08 12:55:18
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 #pragma once 0005 0006 #include <QJsonArray> 0007 #include <QObject> 0008 #include <QSettings> 0009 #include <QUrl> 0010 #include <qjsonarray.h> 0011 0012 class AbstractAccount; 0013 class Relationship; 0014 0015 class Identity : public QObject 0016 { 0017 Q_OBJECT 0018 0019 Q_PROPERTY(QString id READ id NOTIFY identityUpdated) 0020 Q_PROPERTY(QString displayName READ displayName NOTIFY identityUpdated) 0021 Q_PROPERTY(QString displayNameHtml READ displayNameHtml NOTIFY identityUpdated) 0022 Q_PROPERTY(QString username READ username NOTIFY identityUpdated) 0023 Q_PROPERTY(QString bio READ bio NOTIFY identityUpdated) 0024 Q_PROPERTY(QString account READ account NOTIFY identityUpdated) 0025 Q_PROPERTY(QUrl url READ url NOTIFY identityUpdated) 0026 Q_PROPERTY(bool locked READ locked NOTIFY identityUpdated) 0027 Q_PROPERTY(QString visibility READ visibility NOTIFY identityUpdated) 0028 Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY identityUpdated) 0029 Q_PROPERTY(QUrl backgroundUrl READ backgroundUrl NOTIFY identityUpdated) 0030 Q_PROPERTY(int followersCount READ followersCount NOTIFY identityUpdated) 0031 Q_PROPERTY(int followingCount READ followingCount NOTIFY identityUpdated) 0032 Q_PROPERTY(int statusesCount READ statusesCount NOTIFY identityUpdated) 0033 Q_PROPERTY(int permission READ permission NOTIFY identityUpdated) 0034 Q_PROPERTY(QJsonArray fields READ fields NOTIFY identityUpdated) 0035 Q_PROPERTY(Relationship *relationship READ relationship NOTIFY relationshipChanged) 0036 0037 public: 0038 QString id() const; 0039 QString displayName() const; 0040 QString username() const; 0041 QString displayNameHtml() const; 0042 QString bio() const; 0043 QString account() const; 0044 QUrl url() const; 0045 bool locked() const; 0046 QString visibility() const; 0047 QUrl avatarUrl() const; 0048 QUrl backgroundUrl() const; 0049 int followersCount() const; 0050 int followingCount() const; 0051 int statusesCount() const; 0052 int permission() const; 0053 QJsonArray fields() const; 0054 0055 void fromSourceData(const QJsonObject &doc); 0056 void fetchAvatar(const QUrl &avatar_url); 0057 void reparentIdentity(AbstractAccount *parent); 0058 0059 Relationship *relationship() const; 0060 void setRelationship(Relationship *r); 0061 0062 Q_SIGNALS: 0063 void relationshipChanged(); 0064 void identityUpdated(); 0065 0066 private: 0067 QString m_id; 0068 QString m_displayName; 0069 QString m_displayNameHtml; 0070 QString m_username; 0071 QString m_bio; 0072 QString m_account; 0073 bool m_locked; 0074 QString m_visibility; 0075 QUrl m_avatarUrl; 0076 QUrl m_backgroundUrl; 0077 QUrl m_url; 0078 QJsonArray m_fields; 0079 int m_followersCount; 0080 int m_followingCount; 0081 int m_statusesCount; 0082 int m_permission; 0083 Relationship *m_relationship = nullptr; 0084 AbstractAccount *m_parent = nullptr; 0085 };