File: memtesttimelinemodel.cpp

package info (click to toggle)
neochat 25.04.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,424 kB
  • sloc: cpp: 27,289; xml: 704; python: 263; makefile: 12; sh: 1
file content (36 lines) | stat: -rw-r--r-- 1,102 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL

#include "memtesttimelinemodel.h"

#include <Quotient/events/eventcontent.h>
#include <Quotient/events/roommessageevent.h>

using namespace Quotient;

MemTestTimelineModel::MemTestTimelineModel(QObject *parent)
    : MessageModel(parent)
{
    beginResetModel();
    m_connection = Connection::makeMockConnection(u"@bob:example.org"_s);
    m_room = new MemTestRoom(m_connection, u"#memtestroom:example.org"_s, u"memtest-sync.json"_s);

    for (const auto &eventIt : m_room->messageEvents()) {
        Q_EMIT newEventAdded(eventIt.event());
    }

    endResetModel();
}

std::optional<std::reference_wrapper<const RoomEvent>> MemTestTimelineModel::getEventForIndex(QModelIndex index) const
{
    return *m_room->messageEvents().at(index.row()).event();
}

int MemTestTimelineModel::rowCount(const QModelIndex &parent) const
{
    Q_UNUSED(parent);
    return m_room->messageEvents().size();
}

#include "moc_memtesttimelinemodel.cpp"