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 #include "relationship.h"
0005 
0006 #include "account.h"
0007 
0008 using namespace Qt::Literals::StringLiterals;
0009 
0010 Relationship::Relationship(Identity *parent, const QJsonObject &jsonObj)
0011     : QObject(parent)
0012     , m_parent(parent)
0013 {
0014     updateFromJson(jsonObj);
0015 }
0016 
0017 void Relationship::updateFromJson(const QJsonObject &jsonObj)
0018 {
0019     setFollowing(jsonObj["following"_L1].toBool());
0020     setRequested(jsonObj["requested"_L1].toBool());
0021     setEndorsed(jsonObj["endorsed"_L1].toBool());
0022     setFollowedBy(jsonObj["followed_by"_L1].toBool());
0023     setMuting(jsonObj["muting"_L1].toBool());
0024     setMutingNotifications(jsonObj["muting_notifications"_L1].toBool());
0025     setShowingReblogs(jsonObj["showing_reblogs"_L1].toBool());
0026     setNotifying(jsonObj["notifying"_L1].toBool());
0027     setBlocking(jsonObj["blocking"_L1].toBool());
0028     setDomainBlocking(jsonObj["domain_blocking"_L1].toBool());
0029     setBlockedBy(jsonObj["blocked_by"_L1].toBool());
0030     setNote(jsonObj["note"_L1].toString());
0031 }
0032 
0033 bool Relationship::following() const
0034 {
0035     return m_following;
0036 }
0037 
0038 void Relationship::setFollowing(bool following)
0039 {
0040     if (following == m_following) {
0041         return;
0042     }
0043     m_following = following;
0044     Q_EMIT followingChanged();
0045 }
0046 
0047 bool Relationship::requested() const
0048 {
0049     return m_requested;
0050 }
0051 
0052 void Relationship::setRequested(bool requested)
0053 {
0054     if (requested == m_requested) {
0055         return;
0056     }
0057     m_requested = requested;
0058     Q_EMIT requestedChanged();
0059 }
0060 
0061 bool Relationship::endorsed() const
0062 {
0063     return m_endorsed;
0064 }
0065 
0066 void Relationship::setEndorsed(bool endorsed)
0067 {
0068     if (endorsed == m_endorsed) {
0069         return;
0070     }
0071     m_endorsed = endorsed;
0072     Q_EMIT endorsedChanged();
0073 }
0074 
0075 bool Relationship::followedBy() const
0076 {
0077     return m_followedBy;
0078 }
0079 
0080 void Relationship::setFollowedBy(bool followedBy)
0081 {
0082     if (followedBy == m_followedBy) {
0083         return;
0084     }
0085     m_followedBy = followedBy;
0086     Q_EMIT followedByChanged();
0087 }
0088 
0089 bool Relationship::muting() const
0090 {
0091     return m_muting;
0092 }
0093 
0094 void Relationship::setMuting(bool muting)
0095 {
0096     if (muting == m_muting) {
0097         return;
0098     }
0099     m_muting = muting;
0100     Q_EMIT mutingChanged();
0101 }
0102 
0103 bool Relationship::mutingNotifications() const
0104 {
0105     return m_mutingNotifications;
0106 }
0107 
0108 void Relationship::setMutingNotifications(bool mutingNotifications)
0109 {
0110     if (mutingNotifications == m_mutingNotifications) {
0111         return;
0112     }
0113     m_mutingNotifications = mutingNotifications;
0114     Q_EMIT mutingNotificationsChanged();
0115 }
0116 
0117 bool Relationship::showingReblogs() const
0118 {
0119     return m_showingReblogs;
0120 }
0121 
0122 void Relationship::setShowingReblogs(bool showingReblogs)
0123 {
0124     if (showingReblogs == m_showingReblogs) {
0125         return;
0126     }
0127     m_showingReblogs = showingReblogs;
0128     Q_EMIT showingReblogsChanged();
0129 }
0130 
0131 bool Relationship::notifying() const
0132 {
0133     return m_notifying;
0134 }
0135 
0136 void Relationship::setNotifying(bool notifying)
0137 {
0138     if (notifying == m_notifying) {
0139         return;
0140     }
0141     m_notifying = notifying;
0142     Q_EMIT notifyingChanged();
0143 }
0144 
0145 bool Relationship::blocking() const
0146 {
0147     return m_blocking;
0148 }
0149 
0150 void Relationship::setBlocking(bool blocking)
0151 {
0152     if (blocking == m_blocking) {
0153         return;
0154     }
0155     m_blocking = blocking;
0156     Q_EMIT blockingChanged();
0157 }
0158 
0159 bool Relationship::domainBlocking() const
0160 {
0161     return m_domainBlocking;
0162 }
0163 
0164 void Relationship::setDomainBlocking(bool domainBlocking)
0165 {
0166     if (domainBlocking == m_domainBlocking) {
0167         return;
0168     }
0169     m_domainBlocking = domainBlocking;
0170     Q_EMIT domainBlockingChanged();
0171 }
0172 
0173 bool Relationship::blockedBy() const
0174 {
0175     return m_blockedBy;
0176 }
0177 
0178 void Relationship::setBlockedBy(bool blockedBy)
0179 {
0180     if (blockedBy == m_blockedBy) {
0181         return;
0182     }
0183     m_blockedBy = blockedBy;
0184     Q_EMIT blockedByChanged();
0185 }
0186 
0187 QString Relationship::note() const
0188 {
0189     return m_note;
0190 }
0191 
0192 void Relationship::setNote(const QString &note)
0193 {
0194     if (note == m_note) {
0195         return;
0196     }
0197     m_note = note;
0198     Q_EMIT noteChanged();
0199 }
0200 
0201 #include "moc_relationship.cpp"