summary refs log tree commit diff
path: root/src/timeline2/TimelineViewManager.h
blob: 68f6ddb086acad532200df91579d9887579181d9 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once

#include <QQuickView>
#include <QSharedPointer>
#include <QWidget>

#include <mtx/responses.hpp>

#include "Cache.h"
#include "Logging.h"
#include "TimelineModel.h"
#include "Utils.h"

// temporary for stubs
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

class MxcImageProvider;

class TimelineViewManager : public QObject
{
        Q_OBJECT

        Q_PROPERTY(
          TimelineModel *timeline MEMBER timeline_ READ activeTimeline NOTIFY activeTimelineChanged)

public:
        TimelineViewManager(QWidget *parent = 0);
        QWidget *getWidget() const { return container; }

        void initialize(const mtx::responses::Rooms &rooms);
        void addRoom(const QString &room_id);

        void sync(const mtx::responses::Rooms &rooms) {}
        void clearAll() { models.clear(); }

        Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }
        Q_INVOKABLE void openImageOverlay(QString url) const;

signals:
        void clearRoomMessageCount(QString roomid);
        void updateRoomsLastMessage(const QString &user, const DescInfo &info);
        void activeTimelineChanged(TimelineModel *timeline);

public slots:
        void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
        void removeTimelineEvent(const QString &room_id, const QString &event_id) {}
        void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs);

        void setHistoryView(const QString &room_id);

        void queueTextMessage(const QString &msg);
        void queueReplyMessage(const QString &reply, const RelatedInfo &related);
        void queueEmoteMessage(const QString &msg);
        void queueImageMessage(const QString &roomid,
                               const QString &filename,
                               const QString &url,
                               const QString &mime,
                               uint64_t dsize,
                               const QSize &dimensions);
        void queueFileMessage(const QString &roomid,
                              const QString &filename,
                              const QString &url,
                              const QString &mime,
                              uint64_t dsize);
        void queueAudioMessage(const QString &roomid,
                               const QString &filename,
                               const QString &url,
                               const QString &mime,
                               uint64_t dsize);
        void queueVideoMessage(const QString &roomid,
                               const QString &filename,
                               const QString &url,
                               const QString &mime,
                               uint64_t dsize);

private:
        QQuickView *view;
        QWidget *container;
        TimelineModel *timeline_ = nullptr;
        MxcImageProvider *imgProvider;

        QHash<QString, QSharedPointer<TimelineModel>> models;
};

#pragma GCC diagnostic pop