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