Move all timeline relevant models and classes to the module

This commit is contained in:
James Graham
2025-04-10 18:25:45 +00:00
parent 6ff32d0935
commit 3f457774dc
44 changed files with 206 additions and 115 deletions

View File

@@ -0,0 +1,62 @@
// SPDX-FileCopyrightText: 2018-2019 Black Hat <bhat@encom.eu.org>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include "messagemodel.h"
class ReactionModel;
namespace Quotient
{
class RoomEvent;
}
/**
* @class TimelineMessageModel
*
* This class defines the model for visualising the room timeline.
*
* This model covers all event types in the timeline with many of the roles being
* specific to a subset of events. This means the user needs to understand which
* roles will return useful information for a given event type.
*
* @sa NeoChatRoom
*/
class TimelineMessageModel : public MessageModel
{
Q_OBJECT
QML_ELEMENT
public:
explicit TimelineMessageModel(QObject *parent = nullptr);
/**
* @brief Number of rows in the model.
*
* @sa QAbstractItemModel::rowCount
*/
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
private:
void connectNewRoom();
std::optional<std::reference_wrapper<const Quotient::RoomEvent>> getEventForIndex(QModelIndex index) const override;
int rowBelowInserted = -1;
bool resetting = false;
bool movingEvent = false;
int timelineServerIndex() const override;
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
void moveReadMarker(const QString &toEventId);
// Hack to ensure that we don't call endInsertRows when we haven't called beginInsertRows
bool m_initialized = false;
};