File indexing completed on 2024-04-28 16:13:20

0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 #include "timelinemodel.h"
0005 
0006 class AbstractAccount;
0007 
0008 /// TimelineModel to show the last post of an account
0009 ///
0010 /// This expose as well some properties of the user (\see identity)
0011 class AccountModel : public TimelineModel
0012 {
0013     Q_OBJECT
0014 
0015     /// The account id of the account we want to display
0016     Q_PROPERTY(QString accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged)
0017 
0018     /// The identity of the account
0019     Q_PROPERTY(Identity *identity READ identity NOTIFY identityChanged)
0020 
0021     /// The account of the current user
0022     Q_PROPERTY(AbstractAccount *account READ account NOTIFY accountChanged)
0023 
0024     /// This property holds whether the current user is the account displayed by this model
0025     Q_PROPERTY(bool isSelf READ isSelf NOTIFY identityChanged)
0026 
0027     /// Whether or not to exclude replies
0028     Q_PROPERTY(bool excludeReplies MEMBER m_excludeReplies NOTIFY filtersChanged)
0029 
0030     /// Whether or not to exclude boosts
0031     Q_PROPERTY(bool excludeBoosts MEMBER m_excludeBoosts NOTIFY filtersChanged)
0032 
0033     /// Whether or not to exclude pinned posts
0034     Q_PROPERTY(bool excludePinned MEMBER m_excludePinned NOTIFY filtersChanged)
0035 
0036     /// Only include posts that have a media attachment
0037     Q_PROPERTY(bool onlyMedia MEMBER m_onlyMedia NOTIFY filtersChanged)
0038 
0039     /// Search for posts with a specific hashtag, leave blank to not search for any
0040     Q_PROPERTY(QString tagged MEMBER m_tagged NOTIFY filtersChanged)
0041 
0042 public:
0043     explicit AccountModel(QObject *parent = nullptr);
0044 
0045     QString accountId() const;
0046     void setAccountId(const QString &accountId);
0047 
0048     Identity *identity() const;
0049 
0050     QString displayName() const override;
0051     AbstractAccount *account() const;
0052     bool isSelf() const;
0053 
0054     void fillTimeline(const QString &fromId = {}) override;
0055 
0056 Q_SIGNALS:
0057     void identityChanged();
0058     void accountChanged();
0059     void accountIdChanged();
0060     void filtersChanged();
0061 
0062 private:
0063     void updateRelationships();
0064 
0065     std::shared_ptr<Identity> m_identity;
0066     QString m_accountId;
0067 
0068     bool m_excludeReplies = false;
0069     bool m_excludeBoosts = false;
0070     bool m_excludePinned = false;
0071     bool m_onlyMedia = false;
0072     QString m_tagged;
0073 };