File indexing completed on 2024-05-12 05:04:09

0001 // SPDX-FileCopyrightText: 2022 Jeremy Winter <jeremy.winter@tutanota.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 #pragma once
0005 
0006 #include <QJsonObject>
0007 
0008 class Identity;
0009 
0010 class Relationship : public QObject
0011 {
0012     Q_OBJECT
0013 
0014     Q_PROPERTY(bool following READ following WRITE setFollowing NOTIFY followingChanged)
0015     Q_PROPERTY(bool requested READ requested WRITE setRequested NOTIFY requestedChanged)
0016     Q_PROPERTY(bool endorsed READ endorsed WRITE setEndorsed NOTIFY endorsedChanged)
0017     Q_PROPERTY(bool followedBy READ followedBy WRITE setFollowedBy NOTIFY followedByChanged)
0018     Q_PROPERTY(bool muting READ muting WRITE setMuting NOTIFY mutingChanged)
0019     Q_PROPERTY(bool mutingNotifications READ mutingNotifications WRITE setMutingNotifications NOTIFY mutingNotificationsChanged)
0020     Q_PROPERTY(bool showingReblogs READ showingReblogs WRITE setShowingReblogs NOTIFY showingReblogsChanged)
0021     Q_PROPERTY(bool notifying READ notifying WRITE setNotifying NOTIFY notifyingChanged)
0022     Q_PROPERTY(bool blocking READ blocking WRITE setBlocking NOTIFY blockingChanged)
0023     Q_PROPERTY(bool domainBlocking READ domainBlocking WRITE setDomainBlocking NOTIFY domainBlockingChanged)
0024     Q_PROPERTY(bool blockedBy READ blockedBy WRITE setBlockedBy NOTIFY blockedByChanged)
0025     Q_PROPERTY(QString note READ note WRITE setNote NOTIFY noteChanged)
0026 
0027 public:
0028     explicit Relationship(Identity *parent, const QJsonObject &jsonObj);
0029 
0030     void updateFromJson(const QJsonObject &jsonObj);
0031 
0032     Identity *m_parent;
0033 
0034     bool following() const;
0035     void setFollowing(bool following);
0036     bool requested() const;
0037     void setRequested(bool requested);
0038     bool endorsed() const;
0039     void setEndorsed(bool endorsed);
0040     bool followedBy() const;
0041     void setFollowedBy(bool followedBy);
0042     bool muting() const;
0043     void setMuting(bool muting);
0044     bool mutingNotifications() const;
0045     void setMutingNotifications(bool mutingNotifications);
0046     bool showingReblogs() const;
0047     void setShowingReblogs(bool showingReblogs);
0048     bool notifying() const;
0049     void setNotifying(bool notifying);
0050     bool blocking() const;
0051     void setBlocking(bool blocking);
0052     bool domainBlocking() const;
0053     void setDomainBlocking(bool domainBlocking);
0054     bool blockedBy() const;
0055     void setBlockedBy(bool blockedBy);
0056     QString note() const;
0057     void setNote(const QString &note);
0058 
0059 Q_SIGNALS:
0060     void followingChanged();
0061     void requestedChanged();
0062     void endorsedChanged();
0063     void followedByChanged();
0064     void mutingChanged();
0065     void mutingNotificationsChanged();
0066     void showingReblogsChanged();
0067     void notifyingChanged();
0068     void blockingChanged();
0069     void domainBlockingChanged();
0070     void blockedByChanged();
0071     void noteChanged();
0072 
0073 private:
0074     bool m_following = false;
0075     bool m_requested = false;
0076     bool m_endorsed = false;
0077     bool m_followedBy = false;
0078     bool m_muting = false;
0079     bool m_mutingNotifications = false;
0080     bool m_showingReblogs = false;
0081     bool m_notifying = false;
0082     bool m_blocking = false;
0083     bool m_domainBlocking = false;
0084     bool m_blockedBy = false;
0085     QString m_note;
0086 };