File indexing completed on 2024-10-06 07:38:15
0001 // SPDX-FileCopyrightText: 2021 kaniini <https://git.pleroma.social/kaniini> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0003 // SPDX-License-Identifier: GPL-3.0-only 0004 0005 #pragma once 0006 0007 #include "timelinemodel.h" 0008 0009 /// Model for displaying and organizing post threads 0010 /// \see TimelineModel 0011 class ThreadModel : public TimelineModel 0012 { 0013 Q_OBJECT 0014 QML_ELEMENT 0015 0016 Q_PROPERTY(QString postId READ postId WRITE setPostId NOTIFY postIdChanged) 0017 0018 public: 0019 explicit ThreadModel(QObject *parent = nullptr); 0020 0021 /// The post id of the "root" post of the thread 0022 /// \see setPostId 0023 QString postId() const; 0024 0025 /// Set the post id of the "root" post of the thread 0026 /// \see postId 0027 void setPostId(const QString &postId); 0028 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 0031 QString displayName() const override; 0032 void fillTimeline(const QString &fromId = QString()) override; 0033 bool canFetchMore(const QModelIndex &parent) const override; 0034 0035 /// Returns the index of the root post in the model 0036 /// Can be used to find where exactly to position the view 0037 Q_INVOKABLE int getRootIndex() const; 0038 0039 void reset() override; 0040 0041 /// Resets and refreshes the timeline for new posts 0042 Q_INVOKABLE void refresh(); 0043 0044 Q_SIGNALS: 0045 void postIdChanged(); 0046 0047 private: 0048 QString m_postId; 0049 0050 friend class TimelineTest; 0051 };