File indexing completed on 2024-05-12 05:04:15
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include "timelinemodel.h" 0007 0008 class AbstractAccount; 0009 0010 /// Model for the three main timelines (Home, Public, and Federated) 0011 /// \see TimelineModel 0012 class MainTimelineModel : public TimelineModel 0013 { 0014 Q_OBJECT 0015 QML_ELEMENT 0016 0017 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0018 Q_PROPERTY(QString listId READ listId WRITE setListId NOTIFY listIdChanged) 0019 Q_PROPERTY(bool atEnd READ atEnd NOTIFY atEndChanged) 0020 0021 public: 0022 explicit MainTimelineModel(QObject *parent = nullptr); 0023 0024 /// Name of the timeline 0025 /// \see setName 0026 QString name() const; 0027 0028 /// Set the name of the timeline to fetch ("home", "public" or "federated") 0029 /// \p name Can be "home", "public", "federated", "bookmarks", "favourites", "trending" or "list" 0030 void setName(const QString &name); 0031 0032 /// Name of the list id 0033 QString listId() const; 0034 0035 /// Set the name of the list to view, only works if name is set to "list" 0036 void setListId(const QString &id); 0037 0038 void fillTimeline(const QString &fromId) override; 0039 QString displayName() const override; 0040 void handleEvent(AbstractAccount::StreamingEventType eventType, const QByteArray &payload) override; 0041 0042 bool atEnd() const; 0043 0044 void reset() override; 0045 0046 Q_SIGNALS: 0047 void atEndChanged(); 0048 void listIdChanged(); 0049 0050 private: 0051 QString m_timelineName; 0052 QString m_listId; 0053 QUrl m_next; 0054 };