Files
neochat/src/timeline/models/timelinemessagemodel.h
James Graham 3d9d211d25 Allow the condition for when messages are automatically marked as read to be configurable.
Title this adds a number of options for when messages should be automatically marked as read for the user to choose from.

![image](/uploads/cef95f8c6c77bfdcabb7a8a309bc1fd2/image.png){width=480 height=262}
2025-07-04 14:36:36 +01:00

57 lines
1.4 KiB
C++

// 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"
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;
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
private:
void connectNewRoom();
std::optional<std::reference_wrapper<const Quotient::RoomEvent>> getEventForIndex(QModelIndex index) const override;
int rowBelowInserted = -1;
int timelineServerIndex() const override;
// Hack to ensure that we don't call endInsertRows when we haven't called beginInsertRows
bool m_initialized = false;
};